nats

package
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler added in v1.0.0

func ErrorHandler(logger *logr.Logger, h HandlerWithErrors) micro.HandlerFunc

ErrorHandler wraps a normal micro endpoint and allows for returning errors natively. Errors are checked and if an error is a client error, details are returned, otherwise a 500 is returned and logged

func HandleNotify added in v1.0.0

func HandleNotify(s micro.Service, healthFuncs ...func(chan<- string, micro.Service)) error

func RequestLogger added in v1.0.0

func RequestLogger(l *logr.Logger, subject string) (*logr.Logger, error)

func SubjectToRequestID added in v1.0.0

func SubjectToRequestID(s string) (string, error)

Types

type ClientError added in v1.0.0

type ClientError interface {
	Error() string
	Code() int
	Body() []byte
}

type ClientOpt

type ClientOpt func(*NATSClient)

func SetGraphQLExecutableSchema

func SetGraphQLExecutableSchema(e graphql.ExecutableSchema) ClientOpt

func SetOptions

func SetOptions(opts ...nats.Option) ClientOpt

func SetServers

func SetServers(s string) ClientOpt

func SetSubject

func SetSubject(s string) ClientOpt

type HandlerWithErrors added in v1.0.0

type HandlerWithErrors func(*logr.Logger, micro.Request) error

type NATSClient

type NATSClient struct {
	Subject string
	Servers string
	Options []nats.Option
	Conn    *nats.Conn
	JS      nats.JetStreamContext
	NATSGraph
}

func NewNATSClient

func NewNATSClient(subject string, servers []string, opts ...ClientOpt) *NATSClient

func (*NATSClient) Connect

func (n *NATSClient) Connect() error

func (*NATSClient) HandleAndLogRequests

func (n *NATSClient) HandleAndLogRequests(m *nats.Msg)

func (*NATSClient) Resolve

func (n *NATSClient) Resolve(errChan chan<- error)

type NATSGraph

type NATSGraph struct {
	ExecutableSchema graphql.ExecutableSchema
	Exec             *executor.Executor
}

type NatsLogger added in v1.0.0

type NatsLogger struct {
	// contains filtered or unexported fields
}

func NewNatsLogger added in v1.0.0

func NewNatsLogger(subject string, nc *nats.Conn) NatsLogger

func (NatsLogger) Write added in v1.0.0

func (n NatsLogger) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL