// 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 }
// 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 }
// 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 }
// 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 }
// 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}) }
// 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 }
// 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}) }
// 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 }
func RegisterArithService(server *rpc.Server, impl Arith) error { return server.RegisterName("Arith", NewArithService(impl)) }
// 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}) }
// 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}) }
func (s *Server) RegisterWithRPC(r *rpc.Server) { server := rpcServer(*s) r.RegisterName("dilithium", &server) }
// 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}) }
// 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}) }
// 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 }
// Registers the appropriate endpoint on an RPC server to serve a // Hook. func RegisterHook(s *rpc.Server, hook packer.Hook) { s.RegisterName("Hook", &HookServer{hook}) }
// Registers the appropriate endpoint on an RPC server to serve a // Packer Environment func RegisterEnvironment(s *rpc.Server, e packer.Environment) { s.RegisterName("Environment", &EnvironmentServer{e}) }
// Registers the appropriate endpoint on an RPC server to serve a // Packer Communicator. func RegisterCommunicator(s *rpc.Server, c packer.Communicator) { s.RegisterName("Communicator", &CommunicatorServer{c}) }
// Registers the appropriate endpoint on an RPC server to serve a // Packer Command. func RegisterCommand(s *rpc.Server, c packer.Command) { s.RegisterName("Command", &CommandServer{c}) }
// Registers the appropriate endpoint on an RPC server to serve a // Packer Cache. func RegisterCache(s *rpc.Server, c packer.Cache) { s.RegisterName("Cache", &CacheServer{c}) }
// Registers the appropriate endpoint on an RPC server to serve a // Packer UI func RegisterUi(s *rpc.Server, ui packer.Ui) { s.RegisterName("Ui", &UiServer{ui}) }
func RegisterArith(server *rpc.Server, i ArithInterface) error { return server.RegisterName("test.1.arith", i) }