Documentation ¶
Overview ¶
Package zebou is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func Broadcast(ctx context.Context, msg *ZeMsg) error
- func RegisterNodesHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterNodesHandlerClient(ctx context.Context, mux *runtime.ServeMux, client NodesClient) error
- func RegisterNodesHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterNodesHandlerServer(ctx context.Context, mux *runtime.ServeMux, server NodesServer) error
- func RegisterNodesServer(s grpc.ServiceRegistrar, srv NodesServer)
- func Send(ctx context.Context, msg *ZeMsg) error
- type Client
- type ConnectionStateHandler
- type ConnectionStateHandlerFunc
- type HandleMessageFunc
- type Handler
- type Hub
- func (s *Hub) Broadcast(ctx context.Context, msg *ZeMsg)
- func (s *Hub) ClientSendChannelFromContext(ctx context.Context) (Sender, error)
- func (s *Hub) GetClientSendChannel(id string) (Sender, error)
- func (s *Hub) Send(ctx context.Context, msg *ZeMsg) error
- func (s *Hub) SendTo(id string, msg *ZeMsg) error
- func (s *Hub) Stop() error
- func (s *Hub) Sync(stream Nodes_SyncServer) error
- type MessageHandler
- type NodesClient
- type NodesServer
- type Nodes_SyncClient
- type Nodes_SyncServer
- type PeerInfo
- type Sender
- type UnimplementedNodesServer
- type UnsafeNodesServer
- type ZeMsg
Constants ¶
This section is empty.
Variables ¶
var File_zebou_proto protoreflect.FileDescriptor
var NoPeerFromContext = errors.New("no peer in attached in context")
var SessionNotFound = errors.New("session not found")
Functions ¶
func RegisterNodesHandler ¶
RegisterNodesHandler registers the http handlers for service Nodes to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterNodesHandlerClient ¶
func RegisterNodesHandlerClient(ctx context.Context, mux *runtime.ServeMux, client NodesClient) error
RegisterNodesHandlerClient registers the http handlers for service Nodes to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "NodesClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "NodesClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "NodesClient" to call the correct interceptors.
func RegisterNodesHandlerFromEndpoint ¶
func RegisterNodesHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterNodesHandlerFromEndpoint is same as RegisterNodesHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterNodesHandlerServer ¶
func RegisterNodesHandlerServer(ctx context.Context, mux *runtime.ServeMux, server NodesServer) error
RegisterNodesHandlerServer registers the http handlers for service Nodes to "mux". UnaryRPC :call NodesServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterNodesHandlerFromEndpoint instead.
func RegisterNodesServer ¶
func RegisterNodesServer(s grpc.ServiceRegistrar, srv NodesServer)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetMessage ¶
func (*Client) SetConnectionSateHandler ¶
func (c *Client) SetConnectionSateHandler(h ConnectionStateHandler)
type ConnectionStateHandler ¶
type ConnectionStateHandler interface {
ConnectionState(active bool)
}
type ConnectionStateHandlerFunc ¶
type ConnectionStateHandlerFunc func(bool)
func (ConnectionStateHandlerFunc) ConnectionState ¶
func (f ConnectionStateHandlerFunc) ConnectionState(active bool)
type HandleMessageFunc ¶
type HandleMessageFunc func(msg *ZeMsg)
type Handler ¶
type Handler interface { NewClient(ctx context.Context, info *PeerInfo) ClientQuit(ctx context.Context, info *PeerInfo) OnMessage(ctx context.Context, msg *ZeMsg) }
Handler is a convenience for hub clients activity handler
type Hub ¶
type Hub struct { UnimplementedNodesServer // contains filtered or unexported fields }
func (*Hub) ClientSendChannelFromContext ¶
ClientSendChannelFromContext returns the client session associated with peer info in context
func (*Hub) GetClientSendChannel ¶
GetClientSendChannel returns the client session associated with id
func (*Hub) Send ¶
Send sends a message to the client associated with context It loads peer info in context to identify client
func (*Hub) Sync ¶
func (s *Hub) Sync(stream Nodes_SyncServer) error
type MessageHandler ¶
type MessageHandler interface {
Handle(message *ZeMsg)
}
MessageHandler is a convenience for message handler
type NodesClient ¶
type NodesClient interface {
Sync(ctx context.Context, opts ...grpc.CallOption) (Nodes_SyncClient, error)
}
NodesClient is the client API for Nodes 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.
func NewNodesClient ¶
func NewNodesClient(cc grpc.ClientConnInterface) NodesClient
type NodesServer ¶
type NodesServer interface { Sync(Nodes_SyncServer) error // contains filtered or unexported methods }
NodesServer is the server API for Nodes service. All implementations must embed UnimplementedNodesServer for forward compatibility
type Nodes_SyncClient ¶
type Nodes_SyncServer ¶
type UnimplementedNodesServer ¶
type UnimplementedNodesServer struct { }
UnimplementedNodesServer must be embedded to have forward compatible implementations.
func (UnimplementedNodesServer) Sync ¶
func (UnimplementedNodesServer) Sync(Nodes_SyncServer) error
type UnsafeNodesServer ¶
type UnsafeNodesServer interface {
// contains filtered or unexported methods
}
UnsafeNodesServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to NodesServer will result in compilation errors.
type ZeMsg ¶
type ZeMsg struct { Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` Encoded []byte `protobuf:"bytes,3,opt,name=encoded,proto3" json:"encoded,omitempty"` // contains filtered or unexported fields }
func (*ZeMsg) Descriptor
deprecated
func (*ZeMsg) GetEncoded ¶
func (*ZeMsg) ProtoMessage ¶
func (*ZeMsg) ProtoMessage()
func (*ZeMsg) ProtoReflect ¶
func (x *ZeMsg) ProtoReflect() protoreflect.Message