nats

package
v0.0.0-...-457f07e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EOS      = "EOS"
	EOSValue = "End-Of-Stream"
)

Variables

This section is empty.

Functions

func DecodeClaims

func DecodeClaims[T any](str string, decoder claimsDecoder[T]) (claims *T, err error)

func DecodeUserClaims

func DecodeUserClaims(str string) (*jwt.UserClaims, error)

func IsEndOfStream

func IsEndOfStream(msg *nats.Msg) (result bool, err error)

func IsEndOfStreamErr

func IsEndOfStreamErr(err error) bool

func NKeyForPublicKey

func NKeyForPublicKey(pk ssh.PublicKey) (string, error)

func NKeyForPublicKeyFile

func NKeyForPublicKeyFile(file *os.File) (string, error)

func NKeyForSigner

func NKeyForSigner(signer ssh.Signer) (string, error)

func NewSigner

func NewSigner(path string) (signer ssh.Signer, err error)

func ReadClaims

func ReadClaims[T any](path string, decoder claimsDecoder[T]) (claims *T, err error)

func ReadClaimsFile

func ReadClaimsFile[T any](file *os.File, decoder claimsDecoder[T]) (claims *T, err error)

func ReadCredentials

func ReadCredentials(path string) (nkey nkeys.KeyPair, jwt string, err error)

func ReadCredentialsFile

func ReadCredentialsFile(file *os.File) (nkey nkeys.KeyPair, jwt string, err error)

func ReadProfile

func ReadProfile(url string) (profile cmd.Profile, nkey nkeys.KeyPair, jwt string, err error)

func ReadUserClaims

func ReadUserClaims(path string) (*jwt.UserClaims, error)

func Request

func Request[Req any, Resp any](conn *nats.EncodedConn, subject string, req Req, resp *Resp, timeout time.Duration) error

func RequestWithContext

func RequestWithContext[Req any, Resp any](ctx context.Context, conn *nats.EncodedConn, subject string, req Req, resp *Resp) (err error)

Types

type CliOptions

type CliOptions struct {
	Url             string `env:"NATS_URL" default:"nats://127.0.0.1:4222" help:"NATS server url."`
	Profile         string `env:"NATS_PROFILE" help:"profile url in the form nsc://<OPERATOR>/<ACCOUNT>/<USER> e.g. nsc://Nits/Numtide/Admin"`
	JwtFile         string `type:"existingfile" env:"NATS_JWT_FILE"`
	HostKeyFile     string `type:"existingfile" env:"NATS_HOST_KEY_FILE"`
	CredentialsFile string `type:"existingfile" env:"NATS_CREDENTIALS_FILE"`
}

func (*CliOptions) Connect

func (c *CliOptions) Connect() (conn *nats.Conn, err error)

func (*CliOptions) ToNatsOptions

func (c *CliOptions) ToNatsOptions() (opts []nats.Option, nkey string, claims *jwt.UserClaims, err error)

type EndOfStreamErr

type EndOfStreamErr struct {
	Subject string
}

func (EndOfStreamErr) Error

func (e EndOfStreamErr) Error() string

type Reader

type Reader struct {
	Sub     *nats.Subscription
	Context context.Context
	// contains filtered or unexported fields
}

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

type RequestError

type RequestError struct {
	Code        string
	Description string
	Data        []byte
}

func (*RequestError) Error

func (r *RequestError) Error() string

type Writer

type Writer struct {
	Conn    *nats.Conn
	Subject string
	Headers nats.Header
}

func (*Writer) Close

func (w *Writer) Close() (err error)

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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