本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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})
}
示例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
}
示例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})
}
示例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
}
示例9: RegisterArithService
func RegisterArithService(server *rpc.Server, impl Arith) error {
return server.RegisterName("Arith", NewArithService(impl))
}
示例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})
}
示例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})
}
示例12: RegisterWithRPC
func (s *Server) RegisterWithRPC(r *rpc.Server) {
server := rpcServer(*s)
r.RegisterName("dilithium", &server)
}
示例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})
}
示例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})
}
示例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
}