nats

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler added in v1.0.1

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.1

func HandleNotify(s micro.Service)

func RequestLogger added in v1.0.1

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

func SubjectToRequestID added in v1.0.1

func SubjectToRequestID(s string) (string, error)

Types

type ClientError added in v1.0.1

type ClientError struct {
	Code    int
	Details string
}

func NewClientError added in v1.0.1

func NewClientError(err error, code int) ClientError

func (ClientError) As added in v1.0.1

func (c ClientError) As(target any) bool

func (*ClientError) Body added in v1.0.1

func (c *ClientError) Body() []byte

func (*ClientError) CodeString added in v1.0.1

func (c *ClientError) CodeString() string

func (ClientError) Error added in v1.0.1

func (c ClientError) Error() string

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.1

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.1

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

func NewNatsLogger added in v1.0.1

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

func (NatsLogger) Write added in v1.0.1

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