nats

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultImage               = "bitnami/nats:2.3.2-debian-10-r0"
	DefaultConfigReloaderImage = "connecteverything/nats-server-config-reloader:0.4.5-v1alpha2"
	DefaultPidFilePath         = "/opt/nats/pid"
	DefaultPidFileName         = "nats-server.pid"
	DefaultConfigPath          = "/opt/nats/conf"
	ConfigFileName             = "nats-config.conf"
	DefaultClientPort          = 4222
	DefaultClusterPort         = 6222
	DefaultHTTPPort            = 8222
	NkeyDir                    = "/etc/nkey"
	NkeySeedFilename           = "seed"
)

Variables

This section is empty.

Functions

func AcquireNATSConnection added in v0.6.1

func AcquireNATSConnection(ctx context.Context, opts ...NatsAcquireOption) (*nats.Conn, error)

!!blocking

default retrier policy :

retrier := backoffv2.Exponential(

backoffv2.WithMaxRetries(0),
backoffv2.WithMinInterval(5*time.Second),
backoffv2.WithMaxInterval(1*time.Minute),
backoffv2.WithMultiplier(1.1),

)

default nats client options:

SeedKey : os.Getenv("NKEY_SEED_FILENAME")

nats.MaxReconnects(-1), nats.CustomReconnectDelay(

func(i int) time.Duration {
	if i == 1 {
		retryBackoff.Reset()
	}
	return retryBackoff.NextBackOff()
},

), nats.DisconnectErrHandler(

func(nc *nats.Conn, err error) {
	lg.Error(err)
},

),

func BuildK8sServiceUrl added in v0.9.0

func BuildK8sServiceUrl(name string, namespace string, port ...int32) string

func ExternalNatsObjects

func ExternalNatsObjects(
	ctx context.Context,
	k8sClient client.Client,
	namespacedNats types.NamespacedName,
) (
	envVars []corev1.EnvVar,
	volumeMounts []corev1.VolumeMount,
	volumes []corev1.Volume,
)

func NatsObjectNameFromURL added in v0.8.0

func NatsObjectNameFromURL(url string) string

func NewDurableReplayConsumer added in v0.8.0

func NewDurableReplayConsumer(mgr nats.JetStreamContext, streamName string, consumerConfig *nats.ConsumerConfig) error

func NewPersistentStream added in v0.6.1

func NewPersistentStream(mgr nats.JetStreamContext, streamConfig *nats.StreamConfig) error

Types

type NatsAcquireOption added in v0.8.2

type NatsAcquireOption func(*natsAcquireOptions)

func WithCreateStreams added in v0.6.1

func WithCreateStreams(streamNames ...*nats.StreamConfig) NatsAcquireOption

func WithLogger added in v0.6.1

func WithLogger(lg *zap.SugaredLogger) NatsAcquireOption

func WithNatsOptions added in v0.6.1

func WithNatsOptions(opts []nats.Option) NatsAcquireOption

func WithRetrier added in v0.6.1

func WithRetrier(retrier backoffv2.Policy) NatsAcquireOption

Jump to

Keyboard shortcuts

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