Documentation ¶
Index ¶
- Constants
- Variables
- func NewNATSGRPCClientToGreeterServer(ctx context.Context, nc *nats.Conn, client GreeterClient, cfg micro.Config, ...) (micro.Service, error)
- func NewNATSGreeterServer(ctx context.Context, nc *nats.Conn, server GreeterServer, cfg micro.Config, ...) (micro.Service, error)
- func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer)
- type ConcurrentService
- func (m *ConcurrentService) AddEndpoint(name string, handler micro.Handler, opts ...micro.EndpointOpt) error
- func (m *ConcurrentService) AddGroup(group string, opts ...micro.GroupOpt) micro.Group
- func (m *ConcurrentService) Info() micro.Info
- func (m *ConcurrentService) Reset()
- func (m *ConcurrentService) Stats() micro.Stats
- func (m *ConcurrentService) Stop() error
- func (m *ConcurrentService) Stopped() bool
- type ConcurrentServiceOption
- type GreeterClient
- type GreeterServer
- type HelloReply
- type HelloRequest
- type JobHandler
- type NATSGreeterClient
- func (c *NATSGreeterClient) SaveMetadata(ctx context.Context, req *structpb.Struct) (*structpb.Struct, error)
- func (c *NATSGreeterClient) SayGoodbye(ctx context.Context, req *SayGoodbyeRequest) (*SayGoodbyeReply, error)
- func (c *NATSGreeterClient) SayHello(ctx context.Context, req *HelloRequest) (*HelloReply, error)
- func (c *NATSGreeterClient) SayHelloAgain(ctx context.Context, req *HelloRequest) (*HelloReply, error)
- type SayGoodbyeReply
- type SayGoodbyeRequest
- type UnimplementedGreeterServer
- func (UnimplementedGreeterServer) SaveMetadata(context.Context, *structpb.Struct) (*structpb.Struct, error)
- func (UnimplementedGreeterServer) SayGoodbye(context.Context, *SayGoodbyeRequest) (*SayGoodbyeReply, error)
- func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error)
- func (UnimplementedGreeterServer) SayHelloAgain(context.Context, *HelloRequest) (*HelloReply, error)
- type UnsafeGreeterServer
Constants ¶
const ( Greeter_SayHello_FullMethodName = "/example.Greeter/SayHello" Greeter_SayHelloAgain_FullMethodName = "/example.Greeter/SayHelloAgain" Greeter_SayGoodbye_FullMethodName = "/example.Greeter/SayGoodbye" Greeter_SaveMetadata_FullMethodName = "/example.Greeter/SaveMetadata" )
Variables ¶
var File_example_proto protoreflect.FileDescriptor
var File_messages_proto protoreflect.FileDescriptor
var Greeter_ServiceDesc = grpc.ServiceDesc{ ServiceName: "example.Greeter", HandlerType: (*GreeterServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "SayHello", Handler: _Greeter_SayHello_Handler, }, { MethodName: "SayHelloAgain", Handler: _Greeter_SayHelloAgain_Handler, }, { MethodName: "SayGoodbye", Handler: _Greeter_SayGoodbye_Handler, }, { MethodName: "SaveMetadata", Handler: _Greeter_SaveMetadata_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "example.proto", }
Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func NewNATSGRPCClientToGreeterServer ¶
func NewNATSGRPCClientToGreeterServer(ctx context.Context, nc *nats.Conn, client GreeterClient, cfg micro.Config, opts ...ConcurrentServiceOption) (micro.Service, error)
NewNATSGRPCClientToGreeterServer returns the gRPC server wrapping a gRPC client as a NATS micro service.
Example:
nc, err := nats.Connect(ns.ClientURL()) if err != nil { panic(err) } var opts := []grpc.DailOption conn, err := grpc.NewClient("localhost:1234", opts...) if err != nil { panic(err) } defer conn.Close() client := NewGreeterClient(conn) cfg := micro.Config{ Name: "GreeterWrapper-Demo", Version: "1.0.0", QueueGroup: "example", Description: "NATS micro service adaptor wrapping GreeterClient", } mc, err := NewNATSGRPCClientToGreeterServer(context.Background(), nc, client, cfg) if err != nil { panic(err) } fmt.Printf("%s -> %s\n", mc.Info().Name, mc.Info().ID)
func NewNATSGreeterServer ¶
func NewNATSGreeterServer(ctx context.Context, nc *nats.Conn, server GreeterServer, cfg micro.Config, opts ...ConcurrentServiceOption) (micro.Service, error)
NewNATSGreeterServer returns the gRPC server as a NATS micro service.
Example:
nc, err := nats.Connect(ns.ClientURL()) if err != nil { panic(err) } cfg := micro.Config{ Name: "GreeterServer-Demo", Version: "1.0.0", QueueGroup: "example", Description: "NATS micro service adaptor wrapping GreeterServer", } mc, err := NewNATSGreeterServer(context.Background(), nc, GreeterService{}, cfg) if err != nil { panic(err) } fmt.Printf("%s -> %s\n", mc.Info().Name, mc.Info().ID)
func RegisterGreeterServer ¶
func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer)
Types ¶
type ConcurrentService ¶
type ConcurrentService struct {
// contains filtered or unexported fields
}
ConcurrentService is a wrapper around the micro.Service interface, extending with additional functionality.
func (*ConcurrentService) AddEndpoint ¶
func (m *ConcurrentService) AddEndpoint(name string, handler micro.Handler, opts ...micro.EndpointOpt) error
AddEndpoint registers endpoint with given name on a specific subject.
func (*ConcurrentService) AddGroup ¶
AddGroup returns a Group interface, allowing for more complex endpoint topologies. A group can be used to register endpoints with given prefix.
func (*ConcurrentService) Info ¶
func (m *ConcurrentService) Info() micro.Info
Info returns the service info.
func (*ConcurrentService) Reset ¶
func (m *ConcurrentService) Reset()
Reset resets all statistics (for all endpoints) on a service instance.
func (*ConcurrentService) Stats ¶
func (m *ConcurrentService) Stats() micro.Stats
Stats returns statistics for the service endpoint and all monitoring endpoints.
func (*ConcurrentService) Stop ¶
func (m *ConcurrentService) Stop() error
Stop drains the endpoint subscriptions and marks the service as stopped.
func (*ConcurrentService) Stopped ¶
func (m *ConcurrentService) Stopped() bool
Stopped informs whether [Stop] was executed on the service.
type ConcurrentServiceOption ¶
type ConcurrentServiceOption func(*ConcurrentService)
ConcurrentServiceOption is a function used to configure a ConcurrentService.
func WithConcurrentJobs ¶
func WithConcurrentJobs(jobs int) ConcurrentServiceOption
WithConcurrentJobs sets the number of concurrent jobs to be executed.
type GreeterClient ¶
type GreeterClient interface { // Sends a greeting SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) // Sends another greeting SayHelloAgain(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) SayGoodbye(ctx context.Context, in *SayGoodbyeRequest, opts ...grpc.CallOption) (*SayGoodbyeReply, error) SaveMetadata(ctx context.Context, in *structpb.Struct, opts ...grpc.CallOption) (*structpb.Struct, error) }
GreeterClient is the client API for Greeter service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
The greeting service definition.
func NewGreeterClient ¶
func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient
type GreeterServer ¶
type GreeterServer interface { // Sends a greeting SayHello(context.Context, *HelloRequest) (*HelloReply, error) // Sends another greeting SayHelloAgain(context.Context, *HelloRequest) (*HelloReply, error) SayGoodbye(context.Context, *SayGoodbyeRequest) (*SayGoodbyeReply, error) SaveMetadata(context.Context, *structpb.Struct) (*structpb.Struct, error) // contains filtered or unexported methods }
GreeterServer is the server API for Greeter service. All implementations must embed UnimplementedGreeterServer for forward compatibility.
The greeting service definition.
type HelloReply ¶
type HelloReply struct { Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
The response message containing the greetings
func (*HelloReply) Descriptor
deprecated
func (*HelloReply) Descriptor() ([]byte, []int)
Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.
func (*HelloReply) GetMessage ¶
func (x *HelloReply) GetMessage() string
func (*HelloReply) ProtoMessage ¶
func (*HelloReply) ProtoMessage()
func (*HelloReply) ProtoReflect ¶
func (x *HelloReply) ProtoReflect() protoreflect.Message
func (*HelloReply) Reset ¶
func (x *HelloReply) Reset()
func (*HelloReply) String ¶
func (x *HelloReply) String() string
type HelloRequest ¶
type HelloRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
The request message containing the user's name.
func (*HelloRequest) Descriptor
deprecated
func (*HelloRequest) Descriptor() ([]byte, []int)
Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
func (*HelloRequest) GetName ¶
func (x *HelloRequest) GetName() string
func (*HelloRequest) ProtoMessage ¶
func (*HelloRequest) ProtoMessage()
func (*HelloRequest) ProtoReflect ¶
func (x *HelloRequest) ProtoReflect() protoreflect.Message
func (*HelloRequest) Reset ¶
func (x *HelloRequest) Reset()
func (*HelloRequest) String ¶
func (x *HelloRequest) String() string
type JobHandler ¶
type JobHandler struct {
// contains filtered or unexported fields
}
JobHandler is job handler for the concurrent service.
type NATSGreeterClient ¶
type NATSGreeterClient struct {
// contains filtered or unexported fields
}
NATSGreeterClient is a client connecting to a NATS GreeterServer.
func NewNATSGreeterClient ¶
func NewNATSGreeterClient(nc *nats.Conn, name string) *NATSGreeterClient
NewNATSGreeterClient returns a new GreeterServer client. Example:
nc, err := nats.Connect(ns.ClientURL()) if err != nil { panic(err) } client := NewNATSGreeterClient(nc, "example-service-name")
func (*NATSGreeterClient) SaveMetadata ¶
func (*NATSGreeterClient) SayGoodbye ¶
func (c *NATSGreeterClient) SayGoodbye(ctx context.Context, req *SayGoodbyeRequest) (*SayGoodbyeReply, error)
func (*NATSGreeterClient) SayHello ¶
func (c *NATSGreeterClient) SayHello(ctx context.Context, req *HelloRequest) (*HelloReply, error)
Sends a greeting
func (*NATSGreeterClient) SayHelloAgain ¶
func (c *NATSGreeterClient) SayHelloAgain(ctx context.Context, req *HelloRequest) (*HelloReply, error)
Sends another greeting
type SayGoodbyeReply ¶
type SayGoodbyeReply struct { Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
func (*SayGoodbyeReply) Descriptor
deprecated
func (*SayGoodbyeReply) Descriptor() ([]byte, []int)
Deprecated: Use SayGoodbyeReply.ProtoReflect.Descriptor instead.
func (*SayGoodbyeReply) GetMessage ¶
func (x *SayGoodbyeReply) GetMessage() string
func (*SayGoodbyeReply) ProtoMessage ¶
func (*SayGoodbyeReply) ProtoMessage()
func (*SayGoodbyeReply) ProtoReflect ¶
func (x *SayGoodbyeReply) ProtoReflect() protoreflect.Message
func (*SayGoodbyeReply) Reset ¶
func (x *SayGoodbyeReply) Reset()
func (*SayGoodbyeReply) String ¶
func (x *SayGoodbyeReply) String() string
type SayGoodbyeRequest ¶
type SayGoodbyeRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
func (*SayGoodbyeRequest) Descriptor
deprecated
func (*SayGoodbyeRequest) Descriptor() ([]byte, []int)
Deprecated: Use SayGoodbyeRequest.ProtoReflect.Descriptor instead.
func (*SayGoodbyeRequest) GetName ¶
func (x *SayGoodbyeRequest) GetName() string
func (*SayGoodbyeRequest) ProtoMessage ¶
func (*SayGoodbyeRequest) ProtoMessage()
func (*SayGoodbyeRequest) ProtoReflect ¶
func (x *SayGoodbyeRequest) ProtoReflect() protoreflect.Message
func (*SayGoodbyeRequest) Reset ¶
func (x *SayGoodbyeRequest) Reset()
func (*SayGoodbyeRequest) String ¶
func (x *SayGoodbyeRequest) String() string
type UnimplementedGreeterServer ¶
type UnimplementedGreeterServer struct{}
UnimplementedGreeterServer must be embedded to have forward compatible implementations.
NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.
func (UnimplementedGreeterServer) SaveMetadata ¶
func (UnimplementedGreeterServer) SayGoodbye ¶
func (UnimplementedGreeterServer) SayGoodbye(context.Context, *SayGoodbyeRequest) (*SayGoodbyeReply, error)
func (UnimplementedGreeterServer) SayHello ¶
func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error)
func (UnimplementedGreeterServer) SayHelloAgain ¶
func (UnimplementedGreeterServer) SayHelloAgain(context.Context, *HelloRequest) (*HelloReply, error)
type UnsafeGreeterServer ¶
type UnsafeGreeterServer interface {
// contains filtered or unexported methods
}
UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to GreeterServer will result in compilation errors.