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


Golang Server.RegisterName方法代码示例

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


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

示例1: registerComponent

// registerComponent registers a single Packer RPC component onto
// the RPC server. If id is true, then a unique ID number will be appended
// onto the end of the endpoint.
//
// The endpoint name is returned.
func registerComponent(server *rpc.Server, name string, rcvr interface{}, id bool) string {
	endpoint := name
	if id {
		fmt.Sprintf("%s.%d", endpoint, atomic.AddUint64(&endpointId, 1))
	}

	server.RegisterName(endpoint, rcvr)
	return endpoint
}
开发者ID:Nitron,项目名称:packer,代码行数:14,代码来源:server.go

示例2: Serve

// Serve announces an RPC service on the client using the given name
// (which must currently be unique amongst all clients).
func (c *Client) Serve(clientName string, rpcServer *rpc.Server) error {
	var clientId string
	rpcServer.RegisterName("ClientRPC", clientRPC{}) // TODO better name
	if err := c.Server.Call("Ncnet-publisher.Publish", &clientName, &clientId); err != nil {
		return err
	}
	clientconn, err := ncnet.Dial(c.Importer, clientId)
	if err != nil {
		return err
	}

	go rpcServer.ServeConn(clientconn)
	return nil
}
开发者ID:zenoss,项目名称:rog-go,代码行数:16,代码来源:ncrpc.go

示例3: Register

// Register registers an Otto thing with the RPC server and returns
// the name it is registered under.
func Register(server *rpc.Server, thing interface{}) (name string, err error) {
	nextLock.Lock()
	defer nextLock.Unlock()

	switch t := thing.(type) {
	case app.App:
		name = fmt.Sprintf("Otto%d", nextId)
		err = server.RegisterName(name, &AppServer{App: t})
	default:
		return "", errors.New("Unknown type to register for RPC server.")
	}

	nextId += 1
	return
}
开发者ID:mbrodala,项目名称:otto,代码行数:17,代码来源:rpc.go

示例4: Register

// Register registers a Terraform thing with the RPC server and returns
// the name it is registered under.
func Register(server *rpc.Server, thing interface{}) (name string, err error) {
	nextLock.Lock()
	defer nextLock.Unlock()

	switch t := thing.(type) {
	case terraform.ResourceProvider:
		name = fmt.Sprintf("Terraform%d", nextId)
		err = server.RegisterName(name, &ResourceProviderServer{Provider: t})
	case terraform.ResourceProvisioner:
		name = fmt.Sprintf("Terraform%d", nextId)
		err = server.RegisterName(name, &ResourceProvisionerServer{Provisioner: t})
	default:
		return "", errors.New("Unknown type to register for RPC server.")
	}

	nextId += 1
	return
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:20,代码来源:rpc.go

示例5: RegisterProvisioner

// Registers the appropriate endpoint on an RPC server to serve a packer.Provisioner
func RegisterProvisioner(s *rpc.Server, p packer.Provisioner) {
	s.RegisterName("Provisioner", &ProvisionerServer{p})
}
开发者ID:B-Rich,项目名称:packer,代码行数:4,代码来源:server.go

示例6: RegisterEchoServiceB

// RegisterEchoServiceB publish the given EchoServiceB implementation on the server.
func RegisterEchoServiceB(srv *rpc.Server, x EchoServiceB) error {
	if err := srv.RegisterName("EchoServiceB", x); err != nil {
		return err
	}
	return nil
}
开发者ID:jwk000,项目名称:protorpc,代码行数:7,代码来源:echo.pb.go

示例7: RegisterBuild

// Registers the appropriate endpoint on an RPC server to serve a
// Packer Build.
func RegisterBuild(s *rpc.Server, b packer.Build) {
	s.RegisterName("Build", &BuildServer{b})
}
开发者ID:B-Rich,项目名称:packer,代码行数:5,代码来源:server.go

示例8: RegisterArithService

// RegisterArithService publish the given ArithService implementation on the server.
func RegisterArithService(srv *rpc.Server, x ArithService) error {
	if err := srv.RegisterName("ArithService", x); err != nil {
		return err
	}
	return nil
}
开发者ID:ZhangzheBJUT,项目名称:GoProject,代码行数:7,代码来源:service.pb.go

示例9: RegisterArithService

func RegisterArithService(server *rpc.Server, impl Arith) error {
	return server.RegisterName("Arith", NewArithService(impl))
}
开发者ID:alecthomas,项目名称:go-rpcgen,代码行数:3,代码来源:arithrpc.go

示例10: RegisterBuilder

// Registers the appropriate endpoint on an RPC server to serve a
// Packer Builder.
func RegisterBuilder(s *rpc.Server, b packer.Builder) {
	s.RegisterName("Builder", &BuilderServer{b})
}
开发者ID:B-Rich,项目名称:packer,代码行数:5,代码来源:server.go

示例11: registerEndpoint

// registerEndpoint registers the API endpoint on the given RPC server
// for the given agent.
func registerEndpoint(s *rpc.Server, agent *Agent) error {
	return s.RegisterName("Agent", &rpcEndpoint{agent: agent})
}
开发者ID:nikai3d,项目名称:serf,代码行数:5,代码来源:rpc_endpoint.go

示例12: RegisterWithRPC

func (s *Server) RegisterWithRPC(r *rpc.Server) {
	server := rpcServer(*s)
	r.RegisterName("dilithium", &server)
}
开发者ID:kortschak,项目名称:dilithium,代码行数:4,代码来源:rpc.go

示例13: RegisterArtifact

// Registers the appropriate endpoint on an RPC server to serve an
// Artifact.
func RegisterArtifact(s *rpc.Server, a packer.Artifact) {
	s.RegisterName("Artifact", &ArtifactServer{a})
}
开发者ID:B-Rich,项目名称:packer,代码行数:5,代码来源:server.go

示例14: RegisterPostProcessor

// Registers the appropriate endpoing on an RPC server to serve a
// PostProcessor.
func RegisterPostProcessor(s *rpc.Server, p packer.PostProcessor) {
	s.RegisterName("PostProcessor", &PostProcessorServer{p})
}
开发者ID:B-Rich,项目名称:packer,代码行数:5,代码来源:server.go

示例15: RegisterSuperService

// RegisterSuperService publish the given SuperService implementation on the server.
func RegisterSuperService(srv *rpc.Server, x SuperService) error {
	if err := srv.RegisterName("SuperService", x); err != nil {
		return err
	}
	return nil
}
开发者ID:playnb,项目名称:mustang,代码行数:7,代码来源:message.pb.go


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