Documentation ¶
Overview ¶
Code taken from Matthew Titmus' book "Cloud Native Go" with minor modifications. The modifications are:
- This code runs on the sidecar service, so that it does not have to be duplicated across all services. For that reason, the Circuit function type has been changed to take a message and return a message.
Code taken from Matthew Titmus' book "Cloud Native Go" with minor modifications. The modifications are:
- This code runs on the sidecar service, so that it does not have to be duplicated across all services. For that reason, the Circuit function type has been changed to take a message and return a message.
Index ¶
- Variables
- func AddInterface(msgId MessageIdTyp, i interface{})
- func BlockForever()
- func InitGRPCconn(srv *Server)
- func InitLogs(ctx context.Context, natsConn *Conn, srv *Server)
- func InitPubs(natsConn *Conn, srv *Server)
- func InitSubs(natsConn *Conn, srv *Server)
- func Initconns() (*Conn, *Server, error)
- func NewNATSConnJS(nc *nats.Conn) (nats.JetStreamContext, error)
- func NewRegParams(circuitFailureThreshold uint32, debounceDelay string, retryNum uint32, ...) (*pb.RegistrationParams, error)
- func NextMsgId() uint64
- func RecvFromNATS(ctx context.Context, srv *Server, in *pb.Receive) (*pb.SubTopicResponse, error)
- func RecvJSFromNATS(ctx context.Context, srv *Server, in *pb.ReceiveJS) (*pb.SubJSTopicResponse, error)
- func SendLogsToMsgQueue(ctx context.Context, logs *Logs)
- type Circuit
- type Conn
- type Effector
- type Header
- type Logs
- type Message
- type MessageIdTyp
- type MsgID
- type Pubs
- type RequestIdTyp
- type Server
- func (s *Server) Log(ctx context.Context, in *pb.LogMsg) (*emptypb.Empty, error)
- func (s *Server) Pub(ctx context.Context, in *pb.PubMsg) (*pb.PubMsgResponse, error)
- func (s *Server) PubJS(ctx context.Context, in *pb.PubJSMsg) (*emptypb.Empty, error)
- func (s *Server) Recv(ctx context.Context, in *pb.Receive) (*pb.SubTopicResponse, error)
- func (s *Server) RecvJS(ctx context.Context, in *pb.ReceiveJS) (*pb.SubJSTopicResponse, error)
- func (s *Server) Register(ctx context.Context, in *pb.RegistrationMsg) (*pb.RegistrationMsgResponse, error)
- func (s *Server) Sub(ctx context.Context, in *pb.SubMsg) (*pb.SubMsgResponse, error)
- func (s *Server) SubJS(ctx context.Context, in *pb.SubJSMsg) (*pb.SubJSMsgResponse, error)
- func (s *Server) Unsub(ctx context.Context, in *pb.UnsubMsg) (*pb.UnsubMsgResponse, error)
- func (s *Server) UnsubJS(ctx context.Context, in *pb.UnsubJSMsg) (*pb.UnsubJSMsgResponse, error)
- type ServiceIdTyp
- type ServiceTyp
- type Subs
- func (subs *Subs) Subscribe(in *pb.SubMsg) (*pb.SubMsgResponse, error)
- func (subs *Subs) SubscribeJS(ctx context.Context, in *pb.SubJSMsg) (*pb.SubJSMsgResponse, error)
- func (subs *Subs) Unsubscribe(logger *log.Logger, in *pb.UnsubMsg) (*pb.UnsubMsgResponse, error)
- func (subs *Subs) UnsubscribeJS(logger *log.Logger, in *pb.UnsubJSMsg) (*pb.UnsubJSMsgResponse, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var MsgFunc map[MessageIdTyp][]interface{}
Functions ¶
func AddInterface ¶
func AddInterface(msgId MessageIdTyp, i interface{})
func BlockForever ¶
func BlockForever()
func InitGRPCconn ¶
func InitGRPCconn(srv *Server)
func NewNATSConnJS ¶
func NewNATSConnJS(nc *nats.Conn) (nats.JetStreamContext, error)
func NewRegParams ¶
func RecvFromNATS ¶
func RecvJSFromNATS ¶
func SendLogsToMsgQueue ¶
Types ¶
type Conn ¶
type Conn struct { Url string // contains filtered or unexported fields }
func InitNATSconn ¶
func NewNATSConn ¶
type Header ¶
type Header struct { ServType ServiceTyp ServId ServiceIdTyp ReqId RequestIdTyp MsgId MessageIdTyp }
type MessageIdTyp ¶
type MessageIdTyp uint32
type MsgID ¶
type MsgID struct { Value uint64 // contains filtered or unexported fields }
GRPC creates a different goroutine to handle each request. This value is used by many goroutines. This means we have to keep it as a global, and protect it using a mutex.
type RequestIdTyp ¶
type RequestIdTyp uint64
type Server ¶
type Server struct { pb.UnimplementedSidecarServer GrcpServer *grpc.Server Logs *Logs Pubs *Pubs Subs *Subs // contains filtered or unexported fields }
func (*Server) Register ¶
func (s *Server) Register(ctx context.Context, in *pb.RegistrationMsg) (*pb.RegistrationMsgResponse, error)
func (*Server) UnsubJS ¶
func (s *Server) UnsubJS(ctx context.Context, in *pb.UnsubJSMsg) (*pb.UnsubJSMsgResponse, error)
type ServiceIdTyp ¶
type ServiceIdTyp uint64
type ServiceTyp ¶
type ServiceTyp uint32
type Subs ¶
type Subs struct {
// contains filtered or unexported fields
}
func (*Subs) SubscribeJS ¶
func (*Subs) Unsubscribe ¶
func (*Subs) UnsubscribeJS ¶
func (subs *Subs) UnsubscribeJS(logger *log.Logger, in *pb.UnsubJSMsg) (*pb.UnsubJSMsgResponse, error)
Click to show internal directories.
Click to hide internal directories.