nrpc

package
v0.0.0-...-4d51886 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: BSD-3-Clause Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerAlreadyStarted = errors.New("server already started")
)

Functions

func ParseError

func ParseError(msg *nats.Msg) error

Types

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

A client configuration value

func Timeout

func Timeout(to time.Duration) ClientOption

Set the maximum amount of time the client will wait for a response from a server

type ClientOptions

type ClientOptions struct {
	// Timeout sets the amount of time that a client will
	// wait for a response from the server
	Timeout time.Duration
	// Namespace will be added to the beginning of all NATS
	// subjects used by the client, effectively allowing
	// multiple servers to be run and accessed manually.
	Namespace string
}

Client configuration values

func NewClientOptions

func NewClientOptions(options ...ClientOption) (*ClientOptions, error)

func (*ClientOptions) ApplyNamespace

func (opt *ClientOptions) ApplyNamespace(to string) string

type Error

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

func NewError

func NewError(code int, message string) *Error

func (*Error) Code

func (err *Error) Code() int

func (*Error) Error

func (err *Error) Error() string

func (*Error) Is

func (err *Error) Is(other error) bool

func (*Error) Unwrap

func (err *Error) Unwrap() error

type Option

type Option interface {
	ServerOption
	ClientOption
}

An option that can be used on both the server and client.

func HashNamespace

func HashNamespace(inputs ...string) Option

Generate a namespace by taking a SHA-256 hash of the inputs. This is useful for generating a namespace from values that may have illegal characters for a NATS subject name.

func Namespace

func Namespace(ns string) Option

Set the namespace used for all NATS subjects

type Server

type Server interface {
	// Info returns the service info.
	Info() micro.Info

	// Stats returns statistics for the service endpoint and all monitoring endpoints.
	Stats() micro.Stats

	// Reset resets all statistics (for all endpoints) on a service instance.
	Reset()

	// Stop drains the endpoint subscriptions and marks the service as stopped.
	Stop() error

	// Stopped informs whether [Stop] was executed on the service.
	Stopped() bool
}

type ServerFunc

type ServerFunc func() error

func (ServerFunc) Stop

func (sf ServerFunc) Stop() error

type ServerOption

type ServerOption interface {
	// contains filtered or unexported methods
}

A server configuration value

func BufferSize

func BufferSize(bs int) ServerOption

Set the maximum number of buffered messages for each server endpoint

func ErrorHandler

func ErrorHandler(eh func(error)) ServerOption

Set the error handler for the server.

func QueueGroup

func QueueGroup(qg string) ServerOption

Set the NATS queue group name for the server

type ServerOptions

type ServerOptions struct {
	// Namespace will be added to the beginning of all NATS
	// subjects the server listens on, effectively allowing
	// multiple servers to be run.
	Namespace string
	// QueueGroup can be used to ensure that requests are only
	// sent to a single server when running multiple in parallel.
	QueueGroup string
	// A handler for errors that occur during service calls.
	ErrorHandler func(error)
	// The maximum number of pending messages that each endpoint
	// in the server supports. This size is per-endpoint.
	BufferSize int
}

func NewServerOptions

func NewServerOptions(options ...ServerOption) (*ServerOptions, error)

func (*ServerOptions) ApplyNamespace

func (opt *ServerOptions) ApplyNamespace(to micro.Group) micro.Group

Jump to

Keyboard shortcuts

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