connection

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AuthModeCredsFile = "auth_creds_file"
View Source
const AuthModeJwt = "auth_jwt"
View Source
const AuthModeJwtBearer = "auth_jwt_bearer"
View Source
const AuthModeNKey = "auth_nkey"
View Source
const AuthModeNone = "auth_none"
View Source
const AuthModeToken = "auth_token"
View Source
const AuthModeUserPassword = "auth_user_password"
View Source
const (
	CONNECTION_NAME_NUI_PREFIX = "NUI-"
)
View Source
const StatusConnected = "connected"
View Source
const StatusDisconnected = "disconnected"

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Active   bool   `json:"active"`
	Mode     string `json:"mode"`
	Username string `json:"username"`
	Password string `json:"password"`
	Token    string `json:"token"`
	Jwt      string `json:"jwt"`
	NKeySeed string `json:"n_key_seed" clover:"n_key_seed"`
	Creds    string `json:"creds"`
}

type Conn

type Conn interface {
	Close()
}

type ConnBuilder added in v0.8.0

type ConnBuilder[T Conn] func(connection *Connection) (T, error)

type ConnPool

type ConnPool[T Conn] struct {
	// contains filtered or unexported fields
}

func NewConnPool

func NewConnPool[T Conn](repo ConnRepo, builder ConnBuilder[T]) *ConnPool[T]

func NewNatsConnPool

func NewNatsConnPool(repo ConnRepo) *ConnPool[*NatsConn]

func (*ConnPool[T]) Get

func (p *ConnPool[T]) Get(id string) (T, error)

func (*ConnPool[T]) Purge

func (p *ConnPool[T]) Purge()

func (*ConnPool[T]) Refresh

func (p *ConnPool[T]) Refresh(id string) error

type ConnRepo

type ConnRepo interface {
	All() (map[string]*Connection, error)
	GetById(id string) (*Connection, error)
	Save(c *Connection) (*Connection, error)
	Remove(id string) error
}

type ConnStatusChanged

type ConnStatusChanged struct {
	Status string
	Err    error
}

type Connection

type Connection struct {
	Id            string            `json:"id" `
	Name          string            `json:"name" `
	Hosts         []string          `json:"hosts" `
	InboxPrefix   string            `json:"inbox_prefix"`
	Subscriptions []Subscription    `clover:"subscriptions" json:"subscriptions"`
	Auth          []Auth            `json:"auth"`
	TLSAuth       TLSAuth           `clover:"tls_auth" json:"tls_auth"`
	Metrics       Metrics           `clover:"metrics" json:"metrics"`
	Metadata      map[string]string `clover:"metadata" json:"metadata"`
}

func (*Connection) GetMetadata added in v0.5.0

func (c *Connection) GetMetadata(key string) (string, bool)

func (*Connection) SetMetadata added in v0.5.0

func (c *Connection) SetMetadata(key, value string)

type DocStoreConnRepo

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

func NewDocStoreConnRepo

func NewDocStoreConnRepo(db *docstore.DB) *DocStoreConnRepo

func (*DocStoreConnRepo) All

func (r *DocStoreConnRepo) All() (map[string]*Connection, error)

func (*DocStoreConnRepo) GetById

func (r *DocStoreConnRepo) GetById(id string) (*Connection, error)

func (*DocStoreConnRepo) Remove

func (r *DocStoreConnRepo) Remove(id string) error

func (*DocStoreConnRepo) Save

func (r *DocStoreConnRepo) Save(c *Connection) (*Connection, error)

type MemConnRepo

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

func NewMemConnRepo

func NewMemConnRepo() *MemConnRepo

func (*MemConnRepo) All

func (r *MemConnRepo) All() (map[string]*Connection, error)

func (*MemConnRepo) GetById

func (r *MemConnRepo) GetById(id string) (*Connection, error)

func (*MemConnRepo) Remove

func (r *MemConnRepo) Remove(id string) error

func (*MemConnRepo) Save

func (r *MemConnRepo) Save(c *Connection) (*Connection, error)

type Metrics added in v0.7.1

type Metrics struct {
	HttpSource struct {
		Active bool   `clover:"active" json:"active"`
		Url    string `clover:"url" json:"url"`
	} `clover:"http_source" json:"http_source"`
	NatsSource struct {
		Active bool `clover:"active" json:"active"`
		Auth   Auth `clover:"auth" json:"auth"`
	} `clover:"nats_source" json:"nats_source"`
}

type NatsConn

type NatsConn struct {
	*nats.Conn
	// contains filtered or unexported fields
}

func NatsBuilder added in v0.8.0

func NatsBuilder(connection *Connection) (*NatsConn, error)

func NewNatsConn

func NewNatsConn(hosts string, options ...nats.Option) (*NatsConn, error)

func (*NatsConn) Close

func (n *NatsConn) Close()

func (*NatsConn) LastEvent added in v0.2.1

func (n *NatsConn) LastEvent() (string, error)

func (*NatsConn) ObserveConnectionEvents

func (n *NatsConn) ObserveConnectionEvents(ctx context.Context) <-chan ConnStatusChanged

type Pool

type Pool[T Conn] interface {
	Get(id string) (T, error)
	Refresh(id string) error
	Purge()
}

type Subscription

type Subscription struct {
	Subject string `json:"subject"`
}

type TLSAuth added in v0.4.3

type TLSAuth struct {
	Enabled        bool   `clover:"enabled" json:"enabled"`
	CertPath       string `clover:"cert_path" json:"cert_path"`
	KeyPath        string `clover:"key_path" json:"key_path"`
	CaPath         string `clover:"ca_path" json:"ca_path"`
	HandshakeFirst bool   `clover:"handshake_first" json:"handshake_first"`
}

Jump to

Keyboard shortcuts

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