当前位置: 首页>>代码示例>>Golang>>正文


Golang Server.Shutdown方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/diego-ssh/server.Server.Shutdown方法的典型用法代码示例。如果您正苦于以下问题:Golang Server.Shutdown方法的具体用法?Golang Server.Shutdown怎么用?Golang Server.Shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/diego-ssh/server.Server的用法示例。


在下文中一共展示了Server.Shutdown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

		})

		JustBeforeEach(func() {
			sshProxy = proxy.New(logger.Session("proxy"), proxySSHConfig)
			proxyServer = server.NewServer(logger, "127.0.0.1:0", sshProxy)
			proxyServer.SetListener(proxyListener)
			go proxyServer.Serve()

			sshDaemon = daemon.New(logger.Session("sshd"), daemonSSHConfig, daemonGlobalRequestHandlers, daemonNewChannelHandlers)
			sshdServer = server.NewServer(logger, "127.0.0.1:0", sshDaemon)
			sshdServer.SetListener(sshdListener)
			go sshdServer.Serve()
		})

		AfterEach(func() {
			proxyServer.Shutdown()
			sshdServer.Shutdown()
		})

		Context("when a new connection arrives", func() {
			var clientConfig *ssh.ClientConfig

			BeforeEach(func() {
				clientConfig = &ssh.ClientConfig{
					User: "diego:some-instance-guid",
					Auth: []ssh.AuthMethod{
						ssh.Password("diego-user:diego-password"),
					},
				}
			})
开发者ID:sykesm,项目名称:diego-ssh,代码行数:30,代码来源:proxy_test.go

示例2:

		newChannelHandlers := map[string]handlers.NewChannelHandler{
			"direct-tcpip": handler,
		}

		serverNetConn, clientNetConn := test_helpers.Pipe()

		sshd = daemon.New(logger, serverSSHConfig, nil, newChannelHandlers)
		go sshd.HandleConnection(serverNetConn)

		client = test_helpers.NewClient(clientNetConn, nil)
	})

	AfterEach(func() {
		client.Close()
		echoServer.Shutdown()
	})

	Context("when a session is opened", func() {
		var conn net.Conn

		JustBeforeEach(func() {
			var dialErr error
			conn, dialErr = client.Dial("tcp", echoAddress)
			Expect(dialErr).NotTo(HaveOccurred())
		})

		AfterEach(func() {
			conn.Close()
		})
开发者ID:benjaminharnett,项目名称:diego-ssh,代码行数:29,代码来源:direct_tcpip_channel_handler_test.go

示例3:

		})
	})

	Describe("Shutdown", func() {
		var fakeListener *fake_net.FakeListener

		BeforeEach(func() {
			fakeListener = &fake_net.FakeListener{}

			srv = server.NewServer(logger, address, handler)
			srv.SetListener(fakeListener)
		})

		Context("when the server is shutdown", func() {
			BeforeEach(func() {
				srv.Shutdown()
			})

			It("closes the listener", func() {
				Expect(fakeListener.CloseCallCount()).To(Equal(1))
			})

			It("marks the server as stopping", func() {
				Expect(srv.IsStopping()).To(BeTrue())
			})

			It("does not log an accept failure", func() {
				Eventually(func() error {
					_, err := net.Dial("tcp", address)
					return err
				}).Should(HaveOccurred())
开发者ID:benjaminharnett,项目名称:diego-ssh,代码行数:31,代码来源:server_test.go


注:本文中的github.com/cloudfoundry-incubator/diego-ssh/server.Server.Shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。