63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
|
// Code generated by protoc-gen-micro
|
||
|
// source: transport.proto
|
||
|
package transport
|
||
|
|
||
|
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"
|
||
|
)
|
||
|
|
||
|
// NewTransportEndpoints provides api endpoints metdata for Transport service
|
||
|
func NewTransportEndpoints() []*micro_api.Endpoint {
|
||
|
var endpoints []*micro_api.Endpoint
|
||
|
return endpoints
|
||
|
}
|
||
|
|
||
|
// TransportService interface
|
||
|
type TransportService interface {
|
||
|
Stream(context.Context, ...micro_client.CallOption) (Transport_StreamService, error)
|
||
|
}
|
||
|
|
||
|
type Transport_StreamService interface {
|
||
|
Context() context.Context
|
||
|
SendMsg(interface{}) error
|
||
|
RecvMsg(interface{}) error
|
||
|
Close() error
|
||
|
Send(*Message) error
|
||
|
Recv() (*Message, error)
|
||
|
}
|
||
|
|
||
|
// Micro server stuff
|
||
|
|
||
|
// TransportHandler server handler
|
||
|
type TransportHandler interface {
|
||
|
Stream(context.Context, Transport_StreamStream) error
|
||
|
}
|
||
|
|
||
|
// RegisterTransportHandler registers server handler
|
||
|
func RegisterTransportHandler(s micro_server.Server, sh TransportHandler, opts ...micro_server.HandlerOption) error {
|
||
|
type transport interface {
|
||
|
Stream(context.Context, micro_server.Stream) error
|
||
|
}
|
||
|
type Transport struct {
|
||
|
transport
|
||
|
}
|
||
|
h := &transportHandler{sh}
|
||
|
for _, endpoint := range NewTransportEndpoints() {
|
||
|
opts = append(opts, micro_api.WithEndpoint(endpoint))
|
||
|
}
|
||
|
return s.Handle(s.NewHandler(&Transport{h}, opts...))
|
||
|
}
|
||
|
|
||
|
type Transport_StreamStream interface {
|
||
|
Context() context.Context
|
||
|
SendMsg(interface{}) error
|
||
|
RecvMsg(interface{}) error
|
||
|
Close() error
|
||
|
Send(*Message) error
|
||
|
Recv() (*Message, error)
|
||
|
}
|