connection

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseCoreClient

func CloseCoreClient() error

CloseCoreClient closes the core client connections

func EnsureRelayConnections

func EnsureRelayConnections() error

EnsureRelayConnections is the demand-side guard used by API/data callers that need at least one usable relay connection before issuing a query. It returns nil as soon as any relay is connected; if none are it forces a reconnect attempt against the full index-relay list. This is *not* the right primitive for filling a partial pool — see TopUpRelayConnections for that, and #68 for the production bug where confusing the two semantics let the upstream pool sit at 1/5 indefinitely.

func GetCoreClient

func GetCoreClient() *core.Client

GetCoreClient returns the core client instance

func GetCoreClientStatus

func GetCoreClientStatus() map[string]interface{}

GetCoreClientStatus returns status information about the core client

func GetIndexRelays added in v0.5.0

func GetIndexRelays() []string

GetIndexRelays returns the configured index/seed relays

func InitializeCoreClient

func InitializeCoreClient(serverCfg *cfgType.ServerConfig) error

InitializeCoreClient sets up the global core client with server configuration

func IsCoreClientInitialized

func IsCoreClientInitialized() bool

IsCoreClientInitialized checks if the core client is properly initialized

func SetIndexRelays added in v0.5.0

func SetIndexRelays(relays []string)

SetIndexRelays sets the index/seed relays used for discovery

func StartRelayHealthCheck added in v0.5.0

func StartRelayHealthCheck(ctx context.Context, interval time.Duration)

StartRelayHealthCheck starts a background goroutine to maintain relay connections. It exits when ctx is cancelled so it doesn't outlive the server instance that started it (#93).

func SwitchToIndexRelays added in v0.5.0

func SwitchToIndexRelays() error

SwitchToIndexRelays switches the core client back to the configured index/seed relays — used when a session ends and per-user mailbox connections should be released.

func SwitchToUserRelays added in v0.4.12

func SwitchToUserRelays(publicKey string) error

SwitchToUserRelays switches the core client to use user's cached relays from mailboxes

func TopUpRelayConnections added in v0.5.4

func TopUpRelayConnections() (before, after int, err error)

TopUpRelayConnections attempts to bring the index-relay pool up to its configured target by dialing every relay that isn't currently connected. Already-connected relays are left alone (the pool's Connect is a no-op for them). Returns the (before, after) connection counts so the caller can log meaningfully — this exists because the health check previously logged "reconnection successful" whenever EnsureRelayConnections returned nil, which it does on any-connection-exists, regardless of whether the deficit was actually closed (#68).

Types

This section is empty.

Jump to

Keyboard shortcuts

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