Documentation
¶
Index ¶
- Constants
- func DeleteRequestToken(operator authb.Operator, key string, account ...string) (string, error)
- func GetAccount(nc *nats.Conn, id string) (string, error)
- func NewDiscardLogger() *slog.Logger
- func NewNilLogger() server.Logger
- func NewTestLogger(t testing.TB) *slog.Logger
- func ServerReload(t testing.TB, sys *nats.Conn) error
- type Account
- type AccountJetStream
- type AccountJetStreamOpt
- func DiskMaxStreamBytes(v int64) AccountJetStreamOpt
- func MaxAckPending(v int) AccountJetStreamOpt
- func MaxBytesRequired() AccountJetStreamOpt
- func MaxConsumers(v int) AccountJetStreamOpt
- func MaxMemory(v uint64) AccountJetStreamOpt
- func MaxStore(v uint64) AccountJetStreamOpt
- func MaxStreams(v int) AccountJetStreamOpt
- func MemMaxStreamBytes(v int64) AccountJetStreamOpt
- type Accounts
- type AllowDeny
- type AuthCallout
- type Authorization
- type CaptureLogger
- func (l *CaptureLogger) Debugf(format string, v ...interface{})
- func (l *CaptureLogger) Errorf(format string, v ...interface{})
- func (l *CaptureLogger) Fatalf(format string, v ...interface{})
- func (l *CaptureLogger) Messages() []string
- func (l *CaptureLogger) Noticef(format string, v ...interface{})
- func (l *CaptureLogger) Tracef(format string, v ...interface{})
- func (l *CaptureLogger) Warnf(format string, v ...interface{})
- type Cluster
- type ClusterAuthorization
- type Conf
- type ConnectionPorts
- type Connections
- func (ts *Connections) ClusterURLs() []string
- func (ts *Connections) MaybeConnect(options ...nats.Option) (*nats.Conn, error)
- func (ts *Connections) NatsURLs() []string
- func (ts *Connections) RequireConnect(opts ...nats.Option) *nats.Conn
- func (ts *Connections) Shutdown()
- func (ts *Connections) TrackConn(conn ...*nats.Conn)
- func (ts *Connections) UntrackedConnection(opts ...nats.Option) (*nats.Conn, error)
- func (ts *Connections) WsMaybeConnect(opts ...nats.Option) (*nats.Conn, error)
- func (ts *Connections) WsURLs() []string
- type ErrorDetails
- type ExternalNatsServer
- type JetStream
- type LeafNodes
- type NatsServer
- type NilLogger
- func (l *NilLogger) Debugf(format string, v ...interface{})
- func (l *NilLogger) Errorf(format string, v ...interface{})
- func (l *NilLogger) Fatalf(format string, v ...interface{})
- func (l *NilLogger) Noticef(format string, v ...interface{})
- func (l *NilLogger) Tracef(format string, v ...interface{})
- func (l *NilLogger) Warnf(format string, v ...interface{})
- type Options
- type Permissions
- type Ports
- type Remote
- type Resolver
- type ResolverConf
- type ResolverListResponse
- type ResolverResponse
- type ResolverType
- type ResolverUpdateResponse
- type ServerDetails
- type TestDir
- type TestHandler
- type UpdateData
- type User
- type UserData
- type UserInfo
- type Users
- type WebSocket
Constants ¶
const UserInfoSubj = "$SYS.REQ.USER.INFO"
Variables ¶
This section is empty.
Functions ¶
func DeleteRequestToken ¶ added in v0.0.13
func NewDiscardLogger ¶ added in v0.1.20
NewDiscardLogger creates a new slog.Logger that discards all output
func NewNilLogger ¶ added in v0.0.7
func NewTestLogger ¶
NewTestLogger creates a new slog.Logger that outputs to testing.TB
Types ¶
type Account ¶ added in v0.0.4
type Account struct {
Users Users `json:"users,omitempty"`
JetStream *AccountJetStream `json:"jetstream,omitempty"`
}
func (*Account) DisableJetStream ¶ added in v0.1.17
func (a *Account) DisableJetStream()
func (*Account) EnableJetStream ¶ added in v0.1.17
func (a *Account) EnableJetStream(opts ...AccountJetStreamOpt)
type AccountJetStream ¶ added in v0.1.22
type AccountJetStream struct {
Enabled bool `json:"-"`
MaxMemory uint64 `json:"max_memory,omitempty"`
MaxStore uint64 `json:"max_store,omitempty"`
MaxStreams int `json:"max_streams,omitempty"`
MaxConsumers int `json:"max_consumers,omitempty"`
MaxBytesRequired bool `json:"max_bytes_required,omitempty"`
MemMaxStreamBytes int64 `json:"mem_max_stream_bytes,omitempty"`
DiskMaxStreamBytes int64 `json:"disk_max_stream_bytes,omitempty"`
MaxAckPending int `json:"max_ack_pending,omitempty"`
}
AccountJetStream represents per-account JetStream configuration. Marshals as "enabled"/"disabled" when no settings are set, or as an object with settings.
func (AccountJetStream) MarshalJSON ¶ added in v0.1.22
func (a AccountJetStream) MarshalJSON() ([]byte, error)
func (*AccountJetStream) UnmarshalJSON ¶ added in v0.1.22
func (a *AccountJetStream) UnmarshalJSON(data []byte) error
type AccountJetStreamOpt ¶ added in v0.1.22
type AccountJetStreamOpt func(*AccountJetStream)
func DiskMaxStreamBytes ¶ added in v0.1.22
func DiskMaxStreamBytes(v int64) AccountJetStreamOpt
func MaxAckPending ¶ added in v0.1.22
func MaxAckPending(v int) AccountJetStreamOpt
func MaxBytesRequired ¶ added in v0.1.22
func MaxBytesRequired() AccountJetStreamOpt
func MaxConsumers ¶ added in v0.1.22
func MaxConsumers(v int) AccountJetStreamOpt
func MaxMemory ¶ added in v0.1.22
func MaxMemory(v uint64) AccountJetStreamOpt
func MaxStore ¶ added in v0.1.22
func MaxStore(v uint64) AccountJetStreamOpt
func MaxStreams ¶ added in v0.1.22
func MaxStreams(v int) AccountJetStreamOpt
func MemMaxStreamBytes ¶ added in v0.1.22
func MemMaxStreamBytes(v int64) AccountJetStreamOpt
type AllowDeny ¶
type AllowDeny struct {
Allow jwt.StringList `json:"allow,omitempty"`
Deny jwt.StringList `json:"deny,omitempty"`
}
AllowDeny block
type AuthCallout ¶ added in v0.0.4
type AuthCallout struct {
// AuthUsers is a list of authorized users under Account that will handle callout requests
AuthUsers jwt.StringList `json:"auth_users"`
// Account containing the AuthUsers
Account string `json:"account,omitempty"`
// Issuer the public key that will issue jwt.AuthorizationResponseClaims
Issuer string `json:"issuer"`
// XKey optional public curve key, activates encryption
XKey string `json:"xkey,omitempty"`
// AllowedAccounts optional public list of accounts that users can be placed in
AllowedAccounts jwt.StringList `json:"allowed_accounts,omitempty"`
}
type Authorization ¶
type Authorization struct {
Token string `json:"token,omitempty"`
Users Users `json:"users,omitempty"`
AuthCallout *AuthCallout `json:"auth_callout,omitempty"`
}
Authorization block
type CaptureLogger ¶ added in v0.1.21
type CaptureLogger struct {
// contains filtered or unexported fields
}
CaptureLogger implements server.Logger and captures all messages.
func NewCaptureLogger ¶ added in v0.1.21
func NewCaptureLogger() *CaptureLogger
func (*CaptureLogger) Debugf ¶ added in v0.1.21
func (l *CaptureLogger) Debugf(format string, v ...interface{})
func (*CaptureLogger) Errorf ¶ added in v0.1.21
func (l *CaptureLogger) Errorf(format string, v ...interface{})
func (*CaptureLogger) Fatalf ¶ added in v0.1.21
func (l *CaptureLogger) Fatalf(format string, v ...interface{})
func (*CaptureLogger) Messages ¶ added in v0.1.21
func (l *CaptureLogger) Messages() []string
Messages returns a copy of all captured messages.
func (*CaptureLogger) Noticef ¶ added in v0.1.21
func (l *CaptureLogger) Noticef(format string, v ...interface{})
func (*CaptureLogger) Tracef ¶ added in v0.1.21
func (l *CaptureLogger) Tracef(format string, v ...interface{})
func (*CaptureLogger) Warnf ¶ added in v0.1.21
func (l *CaptureLogger) Warnf(format string, v ...interface{})
type Cluster ¶ added in v0.1.3
type Cluster struct {
Name string `json:"name,omitempty"`
Port int `json:"port,omitempty"`
NoAdvertise bool `json:"no_advertise,omitempty"`
ConnectRetries int `json:"connect_retries,omitempty"`
Authorization *ClusterAuthorization `json:"authorization,omitempty"`
Routes []string `json:"routes,omitempty"`
}
type ClusterAuthorization ¶ added in v0.1.3
type Conf ¶
type Conf struct {
PortsFileDir string `json:"ports_file_dir,omitempty"`
Debug bool `json:"debug,omitempty"`
Trace bool `json:"trace,omitempty"`
Port int `json:"port,omitempty"`
Include string `json:"include,omitempty"`
Accounts Accounts `json:"accounts,omitempty"`
SystemAccount *string `json:"system_account,omitempty"`
Authorization Authorization `json:"authorization,omitempty"`
DefaultSentinel string `json:"default_sentinel,omitempty"`
JetStream *JetStream `json:"jetstream,omitempty"`
LeafNodes *LeafNodes `json:"leafnodes,omitempty"`
WriteDeadline string `json:"write_deadline,omitempty"`
WebSocket *WebSocket `json:"websocket,omitempty"`
MonitoringPort int `json:"http,omitempty"`
Cluster *Cluster `json:"cluster,omitempty"`
MaxPending int `json:"max_pending,omitempty"`
}
Conf rudimentary struct representing a configuration, missing most :)
type ConnectionPorts ¶ added in v0.1.0
type Connections ¶ added in v0.1.0
type Connections struct {
ConnectionPorts
sync.Mutex
Conns []*nats.Conn
// contains filtered or unexported fields
}
func (*Connections) ClusterURLs ¶ added in v0.1.3
func (ts *Connections) ClusterURLs() []string
func (*Connections) MaybeConnect ¶ added in v0.1.0
MaybeConnect this connection could fail and tests want to verify it
func (*Connections) NatsURLs ¶ added in v0.1.0
func (ts *Connections) NatsURLs() []string
func (*Connections) RequireConnect ¶ added in v0.1.0
func (ts *Connections) RequireConnect(opts ...nats.Option) *nats.Conn
RequireConnect returns a connection, the server must not have auth enabled
func (*Connections) Shutdown ¶ added in v0.1.0
func (ts *Connections) Shutdown()
func (*Connections) TrackConn ¶ added in v0.1.0
func (ts *Connections) TrackConn(conn ...*nats.Conn)
func (*Connections) UntrackedConnection ¶ added in v0.1.0
func (*Connections) WsMaybeConnect ¶ added in v0.1.0
func (*Connections) WsURLs ¶ added in v0.1.0
func (ts *Connections) WsURLs() []string
type ErrorDetails ¶ added in v0.0.13
type ExternalNatsServer ¶ added in v0.1.0
type ExternalNatsServer struct {
Process *exec.Cmd
Connections
// contains filtered or unexported fields
}
func StartExternalProcessWithConfig ¶ added in v0.1.0
func StartExternalProcessWithConfig(t testing.TB, fp string) *ExternalNatsServer
func (*ExternalNatsServer) Shutdown ¶ added in v0.1.0
func (es *ExternalNatsServer) Shutdown()
type NatsServer ¶
type NatsServer interface {
// RequireConnect creates a connection that is not expected to fail, if it fail test will fail
RequireConnect(opts ...nats.Option) *nats.Conn
// MaybeConnect attempts to create a TCP connection
MaybeConnect(options ...nats.Option) (*nats.Conn, error)
// WsMaybeConnect attempts to create a connection via WebSocket.
WsMaybeConnect(opts ...nats.Option) (*nats.Conn, error)
// TrackConn simply adds a connection made to the server via direct client API to be discarded on ShutDown
TrackConn(conn ...*nats.Conn)
// UntrackedConnection convenience function to create a connection that is not tracked
UntrackedConnection(opts ...nats.Option) (*nats.Conn, error)
// Shutdown stop the server closing all connections initiated via the API if tracked.
Shutdown()
// NatsURLs returns a list of all the connection URLs (tcp)
NatsURLs() []string
// WsURLs returns a list of all the connection URLs (websocket)
WsURLs() []string
// ClusterURLs returns a list of all the cluster connection URLs (tcp)
ClusterURLs() []string
}
func NewNatsServer ¶
func NewNatsServer(dir *TestDir, opts *Options) NatsServer
type NilLogger ¶ added in v0.0.6
type NilLogger struct {
// contains filtered or unexported fields
}
type Options ¶ added in v0.1.0
type Options struct {
Debug bool
Trace bool
ConfigFile string
Port int
JetStream bool
StoreDir string
InProcess bool
}
func DefaultNatsServerOptions ¶
func DefaultNatsServerOptions() *Options
func DefaultNatsServerWithJetStreamOptions ¶
DefaultNatsServerWithJetStreamOptions basic config for supporting JetStream
type Permissions ¶
type Permissions struct {
Pub AllowDeny `json:"publish,omitempty"`
Sub AllowDeny `json:"subscribe,omitempty"`
AllowResponses bool `json:"allow_responses,omitempty"`
}
Permissions block
type Resolver ¶
type Resolver struct {
Type ResolverType `json:"type,omitempty"`
Dir string `json:"dir,omitempty"`
AllowDelete bool `json:"allow_delete,omitempty"`
UpdateInterval string `json:"interval,omitempty"`
Timeout string `json:"timeout,omitempty"`
}
type ResolverConf ¶
type ResolverConf struct {
Conf
Operator string `json:"operator,omitempty"`
SystemAccount string `json:"system_account,omitempty"`
Resolver *Resolver `json:"resolver,omitempty"`
Preload map[string]string `json:"resolver_preload,omitempty"`
}
ResolverConf a Conf using delegated authentication
func ResolverFromAuth ¶
func ResolverFromAuth(t testing.TB, operator authb.Operator) *ResolverConf
func (*ResolverConf) UnmarshalJSON ¶ added in v0.1.5
func (r *ResolverConf) UnmarshalJSON(data []byte) error
UnmarshalJSON custom unmarshaler for ResolverConf
type ResolverListResponse ¶ added in v0.0.13
type ResolverListResponse struct {
ResolverResponse
Accounts []string `json:"data"`
}
func ListAccounts ¶ added in v0.0.13
func ListAccounts(nc *nats.Conn) (*ResolverListResponse, error)
type ResolverResponse ¶ added in v0.0.13
type ResolverResponse struct {
Error *ErrorDetails `json:"error,omitempty"`
Server ServerDetails `json:"server"`
}
func DeleteAccount ¶ added in v0.0.13
func DeleteAccount(nc *nats.Conn, token string) (*ResolverResponse, error)
DeleteAccount will only work if https://github.com/nats-io/nats-server/pull/6427 is merged
type ResolverType ¶ added in v0.0.13
type ResolverType string
const ( FullResolver ResolverType = "FULL" MemResolver ResolverType = "MEMORY" CacheResolver ResolverType = "CACHE" )
type ResolverUpdateResponse ¶ added in v0.0.13
type ResolverUpdateResponse struct {
ResolverResponse
UpdateData UpdateData `json:"data"`
}
func UpdateAccount ¶ added in v0.0.13
func UpdateAccount(nc *nats.Conn, token string) (*ResolverUpdateResponse, error)
type ServerDetails ¶ added in v0.0.4
type TestDir ¶
type TestDir struct {
Dir string
// contains filtered or unexported fields
}
TestDir a directory with some simple powers
type TestHandler ¶ added in v0.1.7
type TestHandler struct {
// contains filtered or unexported fields
}
TestHandler implements slog.Handler and outputs to testing.TB
type UpdateData ¶ added in v0.0.13
type User ¶
type User struct {
User string `json:"user,omitempty"`
Password string `json:"password,omitempty"`
Token string `json:"token,omitempty"`
NKEY string `json:"nkey,omitempty"`
Permissions *Permissions `json:"permissions,omitempty"`
}
User represents Username/Password/Token/Permissions
type UserData ¶ added in v0.0.4
type UserData struct {
User string `json:"user"`
Account string `json:"account"`
Permissions Permissions `json:"permissions"`
Expires int64 `json:"expires"`
}
type UserInfo ¶ added in v0.0.4
type UserInfo struct {
ServerDetails
Data UserData `json:"data"`
}