rename mucpSource to service
This commit is contained in:
parent
a03791c581
commit
ad28b72dd3
@ -14,14 +14,14 @@ var (
|
|||||||
DefaultClient = client.DefaultClient
|
DefaultClient = client.DefaultClient
|
||||||
)
|
)
|
||||||
|
|
||||||
type mucpSource struct {
|
type service struct {
|
||||||
serviceName string
|
serviceName string
|
||||||
key string
|
key string
|
||||||
opts source.Options
|
opts source.Options
|
||||||
client proto.SourceService
|
client proto.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mucpSource) Read() (set *source.ChangeSet, err error) {
|
func (m *service) Read() (set *source.ChangeSet, err error) {
|
||||||
req, err := m.client.Read(context.Background(), &proto.ReadRequest{Path: m.key})
|
req, err := m.client.Read(context.Background(), &proto.ReadRequest{Path: m.key})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -30,7 +30,7 @@ func (m *mucpSource) Read() (set *source.ChangeSet, err error) {
|
|||||||
return toChangeSet(req.Change.ChangeSet), nil
|
return toChangeSet(req.Change.ChangeSet), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mucpSource) Watch() (w source.Watcher, err error) {
|
func (m *service) Watch() (w source.Watcher, err error) {
|
||||||
stream, err := m.client.Watch(context.Background(), &proto.WatchRequest{Key: m.key})
|
stream, err := m.client.Watch(context.Background(), &proto.WatchRequest{Key: m.key})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("watch err: ", err)
|
log.Error("watch err: ", err)
|
||||||
@ -40,11 +40,11 @@ func (m *mucpSource) Watch() (w source.Watcher, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write is unsupported
|
// Write is unsupported
|
||||||
func (m *mucpSource) Write(cs *source.ChangeSet) error {
|
func (m *service) Write(cs *source.ChangeSet) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mucpSource) String() string {
|
func (m *service) String() string {
|
||||||
return "mucp"
|
return "mucp"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,10 +63,10 @@ func NewSource(opts ...source.Option) source.Source {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s := &mucpSource{
|
s := &service{
|
||||||
serviceName: addr,
|
serviceName: addr,
|
||||||
opts: options,
|
opts: options,
|
||||||
client: proto.NewSourceService(addr, DefaultClient),
|
client: proto.NewService(addr, DefaultClient),
|
||||||
}
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
@ -618,32 +618,32 @@ func init() {
|
|||||||
func init() { proto.RegisterFile("proto/mucp.proto", fileDescriptor_942f149553cfb65d) }
|
func init() { proto.RegisterFile("proto/mucp.proto", fileDescriptor_942f149553cfb65d) }
|
||||||
|
|
||||||
var fileDescriptor_942f149553cfb65d = []byte{
|
var fileDescriptor_942f149553cfb65d = []byte{
|
||||||
// 425 bytes of a gzipped FileDescriptorProto
|
// 429 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xdd, 0x6e, 0xd3, 0x30,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xdd, 0x8a, 0xd3, 0x40,
|
||||||
0x14, 0xc7, 0x93, 0xa6, 0xcb, 0xc8, 0xc9, 0x47, 0xab, 0x73, 0x81, 0xa2, 0x08, 0x89, 0x60, 0x09,
|
0x14, 0xc7, 0x9b, 0xb6, 0x9b, 0x9a, 0xd3, 0x24, 0x2d, 0xe7, 0x42, 0x42, 0x10, 0x8c, 0x03, 0x42,
|
||||||
0x29, 0x02, 0xc9, 0x1b, 0xdd, 0x23, 0x8c, 0x3b, 0xb8, 0xf2, 0x84, 0xe0, 0xd6, 0xa4, 0xde, 0x52,
|
0x51, 0x98, 0x5d, 0xbb, 0x8f, 0xb0, 0xde, 0xe9, 0xd5, 0x2c, 0xa2, 0xb7, 0xe3, 0xf4, 0xec, 0xb6,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d9, 0xc4, 0x76, 0x7c, 0xd6, 0xd6, 0x75, 0x75, 0x68, 0x14, 0x65, 0x53, 0x57, 0x77, 0x19, 0x3e,
|
||||||
0x81, 0xda, 0xd5, 0x42, 0x2a, 0x5e, 0xb7, 0xe9, 0x45, 0xee, 0x16, 0x1e, 0x3b, 0x16, 0xc8, 0x37,
|
0x83, 0xc8, 0xec, 0x4a, 0xd2, 0x46, 0x96, 0x75, 0x76, 0x51, 0x04, 0xab, 0x89, 0x38, 0x16, 0xd8,
|
||||||
0xf0, 0x8d, 0x15, 0x5c, 0x83, 0xf7, 0x28, 0x7e, 0x69, 0x1b, 0x01, 0x1b, 0xc2, 0xc1, 0x59, 0xcb,
|
0x27, 0x08, 0x9d, 0x15, 0x5c, 0xc2, 0xe4, 0x81, 0xbe, 0x5b, 0x1b, 0x91, 0x68, 0xc3, 0xd6, 0x59,
|
||||||
0x55, 0x65, 0x1d, 0xe8, 0x18, 0x0b, 0x08, 0xca, 0xd1, 0xba, 0x36, 0x10, 0x6e, 0x80, 0x1e, 0x7e,
|
0x2d, 0xcd, 0xd6, 0x3b, 0xb0, 0x31, 0xae, 0x20, 0x52, 0x9d, 0x75, 0x6b, 0x60, 0xbe, 0x06, 0xfe,
|
||||||
0x0c, 0x3b, 0x36, 0xc9, 0x35, 0xc4, 0xb7, 0x9d, 0xe0, 0x4a, 0x30, 0xf1, 0xb3, 0x17, 0x52, 0xe1,
|
0xf8, 0x31, 0xe2, 0xd8, 0x64, 0x57, 0x90, 0xdc, 0x34, 0x24, 0x0d, 0x09, 0xfa, 0x7a, 0x20, 0x6d,
|
||||||
0x6b, 0xf0, 0x4d, 0x57, 0xbf, 0x11, 0x6e, 0x2e, 0xed, 0x1e, 0xb3, 0x65, 0xb2, 0x86, 0x64, 0xdc,
|
0xf0, 0x39, 0x84, 0xae, 0x6b, 0xdf, 0x98, 0xaf, 0x67, 0x7e, 0x4f, 0xf8, 0x32, 0x5b, 0x42, 0xda,
|
||||||
0x90, 0x6d,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, 0xdd, 0x90, 0x38, 0xd7, 0xee, 0x77, 0x5f, 0x7f, 0xdb, 0x37, 0xbf, 0x03, 0x00, 0x00, 0xff,
|
0x7f, 0xd7, 0x3c, 0xe5, 0x83, 0x23, 0xb2, 0xd1, 0x55, 0xf0, 0x39, 0xb4, 0x3f, 0xf7, 0xf5, 0xaf,
|
||||||
0xff, 0x66, 0x66, 0xa8, 0x5d, 0xef, 0x03, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0xff, 0xff, 0xa7, 0x75, 0xb2, 0x55, 0xf0, 0x03, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -31,37 +31,37 @@ var _ context.Context
|
|||||||
var _ client.Option
|
var _ client.Option
|
||||||
var _ server.Option
|
var _ server.Option
|
||||||
|
|
||||||
// Client API for Source service
|
// Client API for Service service
|
||||||
|
|
||||||
type SourceService interface {
|
type Service interface {
|
||||||
Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error)
|
Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error)
|
||||||
Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error)
|
Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error)
|
||||||
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
|
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
|
||||||
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
|
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
|
||||||
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
|
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
|
||||||
Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Source_WatchService, error)
|
Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Service_WatchService, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type sourceService struct {
|
type service struct {
|
||||||
c client.Client
|
c client.Client
|
||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSourceService(name string, c client.Client) SourceService {
|
func NewService(name string, c client.Client) Service {
|
||||||
if c == nil {
|
if c == nil {
|
||||||
c = client.NewClient()
|
c = client.NewClient()
|
||||||
}
|
}
|
||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
name = "source"
|
name = "service"
|
||||||
}
|
}
|
||||||
return &sourceService{
|
return &service{
|
||||||
c: c,
|
c: c,
|
||||||
name: name,
|
name: name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *sourceService) Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) {
|
func (c *service) Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "Source.Create", in)
|
req := c.c.NewRequest(c.name, "Service.Create", in)
|
||||||
out := new(CreateResponse)
|
out := new(CreateResponse)
|
||||||
err := c.c.Call(ctx, req, out, opts...)
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -70,8 +70,8 @@ func (c *sourceService) Create(ctx context.Context, in *CreateRequest, opts ...c
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *sourceService) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) {
|
func (c *service) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "Source.Update", in)
|
req := c.c.NewRequest(c.name, "Service.Update", in)
|
||||||
out := new(UpdateResponse)
|
out := new(UpdateResponse)
|
||||||
err := c.c.Call(ctx, req, out, opts...)
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -80,8 +80,8 @@ func (c *sourceService) Update(ctx context.Context, in *UpdateRequest, opts ...c
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *sourceService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) {
|
func (c *service) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "Source.Delete", in)
|
req := c.c.NewRequest(c.name, "Service.Delete", in)
|
||||||
out := new(DeleteResponse)
|
out := new(DeleteResponse)
|
||||||
err := c.c.Call(ctx, req, out, opts...)
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -90,8 +90,8 @@ func (c *sourceService) Delete(ctx context.Context, in *DeleteRequest, opts ...c
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *sourceService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
|
func (c *service) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "Source.List", in)
|
req := c.c.NewRequest(c.name, "Service.List", in)
|
||||||
out := new(ListResponse)
|
out := new(ListResponse)
|
||||||
err := c.c.Call(ctx, req, out, opts...)
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -100,8 +100,8 @@ func (c *sourceService) List(ctx context.Context, in *ListRequest, opts ...clien
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *sourceService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) {
|
func (c *service) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "Source.Read", in)
|
req := c.c.NewRequest(c.name, "Service.Read", in)
|
||||||
out := new(ReadResponse)
|
out := new(ReadResponse)
|
||||||
err := c.c.Call(ctx, req, out, opts...)
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -110,8 +110,8 @@ func (c *sourceService) Read(ctx context.Context, in *ReadRequest, opts ...clien
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *sourceService) Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Source_WatchService, error) {
|
func (c *service) Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Service_WatchService, error) {
|
||||||
req := c.c.NewRequest(c.name, "Source.Watch", &WatchRequest{})
|
req := c.c.NewRequest(c.name, "Service.Watch", &WatchRequest{})
|
||||||
stream, err := c.c.Stream(ctx, req, opts...)
|
stream, err := c.c.Stream(ctx, req, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -119,33 +119,33 @@ func (c *sourceService) Watch(ctx context.Context, in *WatchRequest, opts ...cli
|
|||||||
if err := stream.Send(in); err != nil {
|
if err := stream.Send(in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &sourceServiceWatch{stream}, nil
|
return &serviceWatch{stream}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Source_WatchService interface {
|
type Service_WatchService interface {
|
||||||
SendMsg(interface{}) error
|
SendMsg(interface{}) error
|
||||||
RecvMsg(interface{}) error
|
RecvMsg(interface{}) error
|
||||||
Close() error
|
Close() error
|
||||||
Recv() (*WatchResponse, error)
|
Recv() (*WatchResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type sourceServiceWatch struct {
|
type serviceWatch struct {
|
||||||
stream client.Stream
|
stream client.Stream
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *sourceServiceWatch) Close() error {
|
func (x *serviceWatch) Close() error {
|
||||||
return x.stream.Close()
|
return x.stream.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *sourceServiceWatch) SendMsg(m interface{}) error {
|
func (x *serviceWatch) SendMsg(m interface{}) error {
|
||||||
return x.stream.Send(m)
|
return x.stream.Send(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *sourceServiceWatch) RecvMsg(m interface{}) error {
|
func (x *serviceWatch) RecvMsg(m interface{}) error {
|
||||||
return x.stream.Recv(m)
|
return x.stream.Recv(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *sourceServiceWatch) Recv() (*WatchResponse, error) {
|
func (x *serviceWatch) Recv() (*WatchResponse, error) {
|
||||||
m := new(WatchResponse)
|
m := new(WatchResponse)
|
||||||
err := x.stream.Recv(m)
|
err := x.stream.Recv(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -154,19 +154,19 @@ func (x *sourceServiceWatch) Recv() (*WatchResponse, error) {
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server API for Source service
|
// Server API for Service service
|
||||||
|
|
||||||
type SourceHandler interface {
|
type ServiceHandler interface {
|
||||||
Create(context.Context, *CreateRequest, *CreateResponse) error
|
Create(context.Context, *CreateRequest, *CreateResponse) error
|
||||||
Update(context.Context, *UpdateRequest, *UpdateResponse) error
|
Update(context.Context, *UpdateRequest, *UpdateResponse) error
|
||||||
Delete(context.Context, *DeleteRequest, *DeleteResponse) error
|
Delete(context.Context, *DeleteRequest, *DeleteResponse) error
|
||||||
List(context.Context, *ListRequest, *ListResponse) error
|
List(context.Context, *ListRequest, *ListResponse) error
|
||||||
Read(context.Context, *ReadRequest, *ReadResponse) error
|
Read(context.Context, *ReadRequest, *ReadResponse) error
|
||||||
Watch(context.Context, *WatchRequest, Source_WatchStream) error
|
Watch(context.Context, *WatchRequest, Service_WatchStream) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterSourceHandler(s server.Server, hdlr SourceHandler, opts ...server.HandlerOption) error {
|
func RegisterServiceHandler(s server.Server, hdlr ServiceHandler, opts ...server.HandlerOption) error {
|
||||||
type source interface {
|
type service interface {
|
||||||
Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error
|
Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error
|
||||||
Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error
|
Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error
|
||||||
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
|
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
|
||||||
@ -174,68 +174,68 @@ func RegisterSourceHandler(s server.Server, hdlr SourceHandler, opts ...server.H
|
|||||||
Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
|
Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
|
||||||
Watch(ctx context.Context, stream server.Stream) error
|
Watch(ctx context.Context, stream server.Stream) error
|
||||||
}
|
}
|
||||||
type Source struct {
|
type Service struct {
|
||||||
source
|
service
|
||||||
}
|
}
|
||||||
h := &sourceHandler{hdlr}
|
h := &serviceHandler{hdlr}
|
||||||
return s.Handle(s.NewHandler(&Source{h}, opts...))
|
return s.Handle(s.NewHandler(&Service{h}, opts...))
|
||||||
}
|
}
|
||||||
|
|
||||||
type sourceHandler struct {
|
type serviceHandler struct {
|
||||||
SourceHandler
|
ServiceHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *sourceHandler) Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error {
|
func (h *serviceHandler) Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error {
|
||||||
return h.SourceHandler.Create(ctx, in, out)
|
return h.ServiceHandler.Create(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *sourceHandler) Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error {
|
func (h *serviceHandler) Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error {
|
||||||
return h.SourceHandler.Update(ctx, in, out)
|
return h.ServiceHandler.Update(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *sourceHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error {
|
func (h *serviceHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error {
|
||||||
return h.SourceHandler.Delete(ctx, in, out)
|
return h.ServiceHandler.Delete(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *sourceHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
|
func (h *serviceHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
|
||||||
return h.SourceHandler.List(ctx, in, out)
|
return h.ServiceHandler.List(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *sourceHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error {
|
func (h *serviceHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error {
|
||||||
return h.SourceHandler.Read(ctx, in, out)
|
return h.ServiceHandler.Read(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *sourceHandler) Watch(ctx context.Context, stream server.Stream) error {
|
func (h *serviceHandler) Watch(ctx context.Context, stream server.Stream) error {
|
||||||
m := new(WatchRequest)
|
m := new(WatchRequest)
|
||||||
if err := stream.Recv(m); err != nil {
|
if err := stream.Recv(m); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return h.SourceHandler.Watch(ctx, m, &sourceWatchStream{stream})
|
return h.ServiceHandler.Watch(ctx, m, &serviceWatchStream{stream})
|
||||||
}
|
}
|
||||||
|
|
||||||
type Source_WatchStream interface {
|
type Service_WatchStream interface {
|
||||||
SendMsg(interface{}) error
|
SendMsg(interface{}) error
|
||||||
RecvMsg(interface{}) error
|
RecvMsg(interface{}) error
|
||||||
Close() error
|
Close() error
|
||||||
Send(*WatchResponse) error
|
Send(*WatchResponse) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type sourceWatchStream struct {
|
type serviceWatchStream struct {
|
||||||
stream server.Stream
|
stream server.Stream
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *sourceWatchStream) Close() error {
|
func (x *serviceWatchStream) Close() error {
|
||||||
return x.stream.Close()
|
return x.stream.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *sourceWatchStream) SendMsg(m interface{}) error {
|
func (x *serviceWatchStream) SendMsg(m interface{}) error {
|
||||||
return x.stream.Send(m)
|
return x.stream.Send(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *sourceWatchStream) RecvMsg(m interface{}) error {
|
func (x *serviceWatchStream) RecvMsg(m interface{}) error {
|
||||||
return x.stream.Recv(m)
|
return x.stream.Recv(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *sourceWatchStream) Send(m *WatchResponse) error {
|
func (x *serviceWatchStream) Send(m *WatchResponse) error {
|
||||||
return x.stream.Send(m)
|
return x.stream.Send(m)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
service Source {
|
service Service {
|
||||||
rpc Create (CreateRequest) returns (CreateResponse) {
|
rpc Create (CreateRequest) returns (CreateResponse) {
|
||||||
}
|
}
|
||||||
rpc Update (UpdateRequest) returns (UpdateResponse) {
|
rpc Update (UpdateRequest) returns (UpdateResponse) {
|
||||||
|
@ -6,10 +6,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type watcher struct {
|
type watcher struct {
|
||||||
stream proto.Source_WatchService
|
stream proto.Service_WatchService
|
||||||
}
|
}
|
||||||
|
|
||||||
func newWatcher(stream proto.Source_WatchService) (source.Watcher, error) {
|
func newWatcher(stream proto.Service_WatchService) (source.Watcher, error) {
|
||||||
return &watcher{stream: stream}, nil
|
return &watcher{stream: stream}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user