config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNATSURL                 = "nats://localhost:4222"
	DefaultReconnectWait           = 50 * time.Millisecond
	DefaultFetchTimeout            = 5 * time.Second
	DefaultAckWaitTimeout          = 30 * time.Second
	DefaultPublishAckTimeout       = 5 * time.Second
	DefaultRetryBaseDelay          = 50 * time.Millisecond
	DefaultHTTPReadTimeout         = 30 * time.Second
	DefaultHTTPWriteTimeout        = 30 * time.Second
	DefaultHTTPIdleTimeout         = 120 * time.Second
	DefaultHTTPShutdownGracePeriod = 30 * time.Second
	DefaultHTTPClientTimeout       = 30 * time.Second
	DefaultHTTPIdleConnTimeout     = 90 * time.Second
	DefaultMaxHeaderBytes          = 1 << 20
)
View Source
const (
	DefaultWorkerCount          = 2
	DefaultFetchBatchSize       = 1
	DefaultMaxDeliver           = 3
	DefaultMaxAckPending        = 1000
	DefaultPublishMaxRetries    = 3
	DefaultMaxIdleConns         = 100
	DefaultMaxIdleConnsPerHost  = 10
	DefaultForEachMaxIterations = 100
	DefaultInboundQueueSize     = 1000
)
View Source
const (
	MaxWorkerCount       = 1000
	MaxFetchBatchSize    = 10000
	MaxAckPending        = 100000
	MaxForEachIterations = 10000
	MaxInboundQueueSize  = 100000
)
View Source
const (
	DefaultConsumerPrefix    = "shunt"
	PublishModeJetStream     = "jetstream"
	PublishModeCore          = "core"
	DefaultPublishMode       = PublishModeJetStream
	DefaultDeliverPolicy     = "new"
	DefaultReplayPolicy      = "instant"
	DefaultLogLevel          = "info"
	DefaultLogEncoding       = "json"
	DefaultLogOutput         = "stdout"
	DefaultMetricsAddress    = ":2112"
	DefaultMetricsPath       = "/metrics"
	DefaultHTTPServerAddress = ":8080"
	DefaultPublicKeyHeader   = "Nats-Public-Key"
	DefaultSignatureHeader   = "Nats-Signature"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthManagerConfig

type AuthManagerConfig struct {
	Enabled   bool                  `json:"enabled" yaml:"enabled"`
	Storage   AuthManagerStorage    `json:"storage" yaml:"storage"`
	Providers []AuthManagerProvider `json:"providers" yaml:"providers"`
}

type AuthManagerProvider

type AuthManagerProvider struct {
	ID            string            `json:"id" yaml:"id"`
	Type          string            `json:"type" yaml:"type"`
	KVKey         string            `json:"kvKey" yaml:"kvKey"`
	RefreshBefore string            `json:"refreshBefore" yaml:"refreshBefore"`
	RefreshEvery  string            `json:"refreshEvery" yaml:"refreshEvery"`
	TokenURL      string            `json:"tokenUrl" yaml:"tokenUrl"`
	ClientID      string            `json:"clientId" yaml:"clientId"`
	ClientSecret  string            `json:"clientSecret" yaml:"clientSecret"`
	Scopes        []string          `json:"scopes" yaml:"scopes"`
	AuthURL       string            `json:"authUrl" yaml:"authUrl"`
	Method        string            `json:"method" yaml:"method"`
	Headers       map[string]string `json:"headers" yaml:"headers"`
	Body          string            `json:"body" yaml:"body"`
	TokenPath     string            `json:"tokenPath" yaml:"tokenPath"`
}

type AuthManagerStorage

type AuthManagerStorage struct {
	Bucket    string `json:"bucket" yaml:"bucket"`
	KeyPrefix string `json:"keyPrefix" yaml:"keyPrefix"`
}

type Config

type Config struct {
	NATS        NATSConfig        `json:"nats" yaml:"nats"`
	HTTP        HTTPConfig        `json:"http,omitempty" yaml:"http,omitempty"`
	Logging     LogConfig         `json:"logging" yaml:"logging"`
	Metrics     MetricsConfig     `json:"metrics" yaml:"metrics"`
	KV          KVConfig          `json:"kv" yaml:"kv"`
	Rules       RulesConfig       `json:"rules" yaml:"rules"`
	Security    SecurityConfig    `json:"security" yaml:"security"`
	ForEach     ForEachConfig     `json:"forEach" yaml:"forEach"`
	Gateway     GatewayConfig     `json:"gateway" yaml:"gateway"`
	AuthManager AuthManagerConfig `json:"authManager" yaml:"authManager"`
}

func Load

func Load(path string) (*Config, error)

func NewDefaults added in v0.1.1

func NewDefaults() *Config

NewDefaults returns a Config populated with all default values. Useful for programmatic config construction (e.g. dev/test commands).

func (*Config) ApplyOverrides

func (c *Config) ApplyOverrides(o ServeOverrides)

type ConnectionConfig

type ConnectionConfig struct {
	MaxReconnects int           `json:"maxReconnects" yaml:"maxReconnects"`
	ReconnectWait time.Duration `json:"reconnectWait" yaml:"reconnectWait"`
}

type ConsumerConfig

type ConsumerConfig struct {
	ConsumerPrefix string        `json:"consumerPrefix" yaml:"consumerPrefix"`
	WorkerCount    int           `json:"workerCount" yaml:"workerCount"`
	FetchBatchSize int           `json:"fetchBatchSize" yaml:"fetchBatchSize"`
	FetchTimeout   time.Duration `json:"fetchTimeout" yaml:"fetchTimeout"`
	MaxAckPending  int           `json:"maxAckPending" yaml:"maxAckPending"`
	AckWaitTimeout time.Duration `json:"ackWaitTimeout" yaml:"ackWaitTimeout"`
	MaxDeliver     int           `json:"maxDeliver" yaml:"maxDeliver"`
	DeliverPolicy  string        `json:"deliverPolicy" yaml:"deliverPolicy"`
	ReplayPolicy   string        `json:"replayPolicy" yaml:"replayPolicy"`
}

type ForEachConfig

type ForEachConfig struct {
	MaxIterations int `json:"maxIterations" yaml:"maxIterations"`
}

type GatewayConfig

type GatewayConfig struct {
	Enabled bool `json:"enabled" yaml:"enabled"`
}

type HTTPClientConfig

type HTTPClientConfig struct {
	Timeout             time.Duration `json:"timeout" yaml:"timeout"`
	MaxIdleConns        int           `json:"maxIdleConns" yaml:"maxIdleConns"`
	MaxIdleConnsPerHost int           `json:"maxIdleConnsPerHost" yaml:"maxIdleConnsPerHost"`
	IdleConnTimeout     time.Duration `json:"idleConnTimeout" yaml:"idleConnTimeout"`
	TLS                 HTTPClientTLS `json:"tls,omitempty" yaml:"tls,omitempty"`
}

type HTTPClientTLS

type HTTPClientTLS struct {
	InsecureSkipVerify bool `json:"insecureSkipVerify" yaml:"insecureSkipVerify"`
}

type HTTPConfig

type HTTPConfig struct {
	Server HTTPServerConfig `json:"server" yaml:"server"`
	Client HTTPClientConfig `json:"client" yaml:"client"`
}

type HTTPServerConfig

type HTTPServerConfig struct {
	Address             string        `json:"address" yaml:"address"`
	ReadTimeout         time.Duration `json:"readTimeout" yaml:"readTimeout"`
	WriteTimeout        time.Duration `json:"writeTimeout" yaml:"writeTimeout"`
	IdleTimeout         time.Duration `json:"idleTimeout" yaml:"idleTimeout"`
	MaxHeaderBytes      int           `json:"maxHeaderBytes" yaml:"maxHeaderBytes"`
	ShutdownGracePeriod time.Duration `json:"shutdownGracePeriod" yaml:"shutdownGracePeriod"`
	InboundWorkerCount  int           `json:"inboundWorkerCount" yaml:"inboundWorkerCount"`
	InboundQueueSize    int           `json:"inboundQueueSize" yaml:"inboundQueueSize"`
}

type KVConfig

type KVConfig struct {
	Enabled       bool     `json:"enabled" yaml:"enabled"`
	AutoProvision bool     `json:"autoProvision" yaml:"autoProvision"`
	Buckets       []string `json:"buckets" yaml:"buckets"`
	LocalCache    struct {
		Enabled bool `json:"enabled" yaml:"enabled"`
	} `json:"localCache" yaml:"localCache"`
}

type LogConfig

type LogConfig struct {
	Level      string `json:"level" yaml:"level"`
	Encoding   string `json:"encoding" yaml:"encoding"`
	OutputPath string `json:"outputPath" yaml:"outputPath"`
}

type MetricsConfig

type MetricsConfig struct {
	Enabled        bool   `json:"enabled" yaml:"enabled"`
	Address        string `json:"address" yaml:"address"`
	Path           string `json:"path" yaml:"path"`
	UpdateInterval string `json:"updateInterval" yaml:"updateInterval"`
}

type NATSConfig

type NATSConfig struct {
	URLs      []string `json:"urls" yaml:"urls"`
	Username  string   `json:"username" yaml:"username"`
	Password  string   `json:"password" yaml:"password"`
	Token     string   `json:"token" yaml:"token"`
	NKey      string   `json:"nkey" yaml:"nkey"`
	CredsFile string   `json:"credsFile" yaml:"credsFile"`

	TLS struct {
		Enable   bool   `json:"enable" yaml:"enable"`
		CertFile string `json:"certFile" yaml:"certFile"`
		KeyFile  string `json:"keyFile" yaml:"keyFile"`
		CAFile   string `json:"caFile" yaml:"caFile"`
		Insecure bool   `json:"insecure" yaml:"insecure"`
	} `json:"tls" yaml:"tls"`

	Consumers  ConsumerConfig   `json:"consumers" yaml:"consumers"`
	Connection ConnectionConfig `json:"connection" yaml:"connection"`
	Publish    PublishConfig    `json:"publish" yaml:"publish"`
}

type PublishConfig

type PublishConfig struct {
	Mode           string        `json:"mode" yaml:"mode"`
	AckTimeout     time.Duration `json:"ackTimeout" yaml:"ackTimeout"`
	MaxRetries     int           `json:"maxRetries" yaml:"maxRetries"`
	RetryBaseDelay time.Duration `json:"retryBaseDelay" yaml:"retryBaseDelay"`
}

type RulesConfig

type RulesConfig struct {
	KVBucket string `json:"kvBucket" yaml:"kvBucket"`
}

type SecurityConfig

type SecurityConfig struct {
	Verification VerificationConfig `json:"verification" yaml:"verification"`
}

type ServeOverrides

type ServeOverrides struct {
	NATSURLs       []string
	LogLevel       string
	MetricsEnabled *bool
	MetricsAddr    string
	MetricsPath    string
	GatewayEnabled *bool
	KVEnabled      *bool
	WorkerCount    *int
}

type VerificationConfig

type VerificationConfig struct {
	Enabled         bool   `json:"enabled" yaml:"enabled"`
	PublicKeyHeader string `json:"publicKeyHeader" yaml:"publicKeyHeader"`
	SignatureHeader string `json:"signatureHeader" yaml:"signatureHeader"`
}

Jump to

Keyboard shortcuts

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