micro-broker-service/proto/broker_micro.pb.go

64 lines
1.7 KiB
Go
Raw Normal View History

// Code generated by protoc-gen-micro
// source: broker.proto
package service
import (
"context"
micro_api "github.com/unistack-org/micro/v3/api"
micro_client "github.com/unistack-org/micro/v3/client"
micro_server "github.com/unistack-org/micro/v3/server"
)
// NewBrokerEndpoints provides api endpoints metdata for Broker service
func NewBrokerEndpoints() []*micro_api.Endpoint {
var endpoints []*micro_api.Endpoint
return endpoints
}
// BrokerService interface
type BrokerService interface {
Publish(context.Context, *PublishRequest, ...micro_client.CallOption) (*Empty, error)
Subscribe(context.Context, *SubscribeRequest, ...micro_client.CallOption) (Broker_SubscribeService, error)
}
type Broker_SubscribeService interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Recv() (*Message, error)
}
// Micro server stuff
// BrokerHandler server handler
type BrokerHandler interface {
Publish(context.Context, *PublishRequest, *Empty) error
Subscribe(context.Context, *SubscribeRequest, Broker_SubscribeStream) error
}
// RegisterBrokerHandler registers server handler
func RegisterBrokerHandler(s micro_server.Server, sh BrokerHandler, opts ...micro_server.HandlerOption) error {
type broker interface {
Publish(context.Context, *PublishRequest, *Empty) error
Subscribe(context.Context, micro_server.Stream) error
}
type Broker struct {
broker
}
h := &brokerHandler{sh}
for _, endpoint := range NewBrokerEndpoints() {
opts = append(opts, micro_api.WithEndpoint(endpoint))
}
return s.Handle(s.NewHandler(&Broker{h}, opts...))
}
type Broker_SubscribeStream interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*Message) error
}