Files
services/stream/proto/stream.pb.micro.go
2021-08-13 12:53:50 +01:00

187 lines
4.7 KiB
Go

// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/stream.proto
package stream
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
_ "google.golang.org/protobuf/types/known/structpb"
math "math"
)
import (
context "context"
api "github.com/micro/micro/v3/service/api"
client "github.com/micro/micro/v3/service/client"
server "github.com/micro/micro/v3/service/server"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for Stream service
func NewStreamEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for Stream service
type StreamService interface {
Publish(ctx context.Context, in *PublishRequest, opts ...client.CallOption) (*PublishResponse, error)
Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Stream_SubscribeService, error)
}
type streamService struct {
c client.Client
name string
}
func NewStreamService(name string, c client.Client) StreamService {
return &streamService{
c: c,
name: name,
}
}
func (c *streamService) Publish(ctx context.Context, in *PublishRequest, opts ...client.CallOption) (*PublishResponse, error) {
req := c.c.NewRequest(c.name, "Stream.Publish", in)
out := new(PublishResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *streamService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Stream_SubscribeService, error) {
req := c.c.NewRequest(c.name, "Stream.Subscribe", &SubscribeRequest{})
stream, err := c.c.Stream(ctx, req, opts...)
if err != nil {
return nil, err
}
if err := stream.Send(in); err != nil {
return nil, err
}
return &streamServiceSubscribe{stream}, nil
}
type Stream_SubscribeService interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Recv() (*SubscribeResponse, error)
}
type streamServiceSubscribe struct {
stream client.Stream
}
func (x *streamServiceSubscribe) Close() error {
return x.stream.Close()
}
func (x *streamServiceSubscribe) Context() context.Context {
return x.stream.Context()
}
func (x *streamServiceSubscribe) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *streamServiceSubscribe) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *streamServiceSubscribe) Recv() (*SubscribeResponse, error) {
m := new(SubscribeResponse)
err := x.stream.Recv(m)
if err != nil {
return nil, err
}
return m, nil
}
// Server API for Stream service
type StreamHandler interface {
Publish(context.Context, *PublishRequest, *PublishResponse) error
Subscribe(context.Context, *SubscribeRequest, Stream_SubscribeStream) error
}
func RegisterStreamHandler(s server.Server, hdlr StreamHandler, opts ...server.HandlerOption) error {
type stream interface {
Publish(ctx context.Context, in *PublishRequest, out *PublishResponse) error
Subscribe(ctx context.Context, stream server.Stream) error
}
type Stream struct {
stream
}
h := &streamHandler{hdlr}
return s.Handle(s.NewHandler(&Stream{h}, opts...))
}
type streamHandler struct {
StreamHandler
}
func (h *streamHandler) Publish(ctx context.Context, in *PublishRequest, out *PublishResponse) error {
return h.StreamHandler.Publish(ctx, in, out)
}
func (h *streamHandler) Subscribe(ctx context.Context, stream server.Stream) error {
m := new(SubscribeRequest)
if err := stream.Recv(m); err != nil {
return err
}
return h.StreamHandler.Subscribe(ctx, m, &streamSubscribeStream{stream})
}
type Stream_SubscribeStream interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*SubscribeResponse) error
}
type streamSubscribeStream struct {
stream server.Stream
}
func (x *streamSubscribeStream) Close() error {
return x.stream.Close()
}
func (x *streamSubscribeStream) Context() context.Context {
return x.stream.Context()
}
func (x *streamSubscribeStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *streamSubscribeStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *streamSubscribeStream) Send(m *SubscribeResponse) error {
return x.stream.Send(m)
}