Documentation
¶
Index ¶
- func DefaultBootstrapPeers() []string
- func DefaultDatabaseEndpoints() []string
- func IsInternalContext(ctx context.Context) bool
- func MapAddrsToDBEndpoints(addrs []multiaddr.Multiaddr, dbPort int) []string
- func WithInternalAuth(ctx context.Context) context.Context
- func WithNamespace(ctx context.Context, ns string) context.Context
- type Client
- func (c *Client) Config() *ClientConfig
- func (c *Client) Connect() error
- func (c *Client) Database() DatabaseClient
- func (c *Client) Disconnect() error
- func (c *Client) Health() (*HealthStatus, error)
- func (c *Client) Network() NetworkInfo
- func (c *Client) PubSub() PubSubClient
- func (c *Client) Storage() StorageClient
- type ClientConfig
- type ColumnInfo
- type DatabaseClient
- type DatabaseClientImpl
- func (d *DatabaseClientImpl) CreateTable(ctx context.Context, schema string) error
- func (d *DatabaseClientImpl) DropTable(ctx context.Context, tableName string) error
- func (d *DatabaseClientImpl) GetSchema(ctx context.Context) (*SchemaInfo, error)
- func (d *DatabaseClientImpl) Query(ctx context.Context, sql string, args ...interface{}) (*QueryResult, error)
- func (d *DatabaseClientImpl) Transaction(ctx context.Context, queries []string) error
- type HealthStatus
- type MessageHandler
- type NetworkClient
- type NetworkInfo
- type NetworkInfoImpl
- func (n *NetworkInfoImpl) ConnectToPeer(ctx context.Context, peerAddr string) error
- func (n *NetworkInfoImpl) DisconnectFromPeer(ctx context.Context, peerID string) error
- func (n *NetworkInfoImpl) GetPeers(ctx context.Context) ([]PeerInfo, error)
- func (n *NetworkInfoImpl) GetStatus(ctx context.Context) (*NetworkStatus, error)
- type NetworkStatus
- type PeerInfo
- type PubSubClient
- type QueryResult
- type SchemaInfo
- type StorageClient
- type StorageClientImpl
- func (s *StorageClientImpl) Get(ctx context.Context, cid string) (io.ReadCloser, error)
- func (s *StorageClientImpl) Pin(ctx context.Context, cid string, name string) (*StoragePinResult, error)
- func (s *StorageClientImpl) Status(ctx context.Context, cid string) (*StorageStatus, error)
- func (s *StorageClientImpl) Unpin(ctx context.Context, cid string) error
- func (s *StorageClientImpl) Upload(ctx context.Context, reader io.Reader, name string) (*StorageUploadResult, error)
- type StoragePinResult
- type StorageStatus
- type StorageUploadResult
- type TableInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBootstrapPeers ¶
func DefaultBootstrapPeers() []string
DefaultBootstrapPeers returns the library's default bootstrap peer multiaddrs. These can be overridden by environment variables or config.
func DefaultDatabaseEndpoints ¶
func DefaultDatabaseEndpoints() []string
DefaultDatabaseEndpoints returns default DB HTTP endpoints. These can be overridden by environment variables or config.
func IsInternalContext ¶
IsInternalContext checks if a context is marked for internal operations
func MapAddrsToDBEndpoints ¶
MapAddrsToDBEndpoints converts a set of peer multiaddrs to DB HTTP endpoints using dbPort.
func WithInternalAuth ¶
WithInternalAuth creates a context that bypasses authentication for internal system operations. This should only be used by the system itself (migrations, internal tasks, etc.)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the NetworkClient interface
func (*Client) Config ¶
func (c *Client) Config() *ClientConfig
Config returns a snapshot copy of the client's configuration
func (*Client) Database ¶
func (c *Client) Database() DatabaseClient
Database returns the database client
func (*Client) Disconnect ¶
Disconnect closes the connection to the network
func (*Client) Health ¶
func (c *Client) Health() (*HealthStatus, error)
Health returns the current health status
func (*Client) Network ¶
func (c *Client) Network() NetworkInfo
Network returns the network info client
func (*Client) Storage ¶ added in v0.69.13
func (c *Client) Storage() StorageClient
Storage returns the storage client
type ClientConfig ¶
type ClientConfig struct {
AppName string `json:"app_name"`
DatabaseName string `json:"database_name"`
BootstrapPeers []string `json:"bootstrap_peers"`
DatabaseEndpoints []string `json:"database_endpoints"`
GatewayURL string `json:"gateway_url"` // Gateway URL for HTTP API access (e.g., "http://localhost:6001")
ConnectTimeout time.Duration `json:"connect_timeout"`
RetryAttempts int `json:"retry_attempts"`
RetryDelay time.Duration `json:"retry_delay"`
QuietMode bool `json:"quiet_mode"` // Suppress debug/info logs
APIKey string `json:"api_key"` // API key for gateway auth
JWT string `json:"jwt"` // Optional JWT bearer token
}
ClientConfig represents configuration for network clients
func DefaultClientConfig ¶
func DefaultClientConfig(appName string) *ClientConfig
DefaultClientConfig returns a default client configuration
type ColumnInfo ¶
type ColumnInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Nullable bool `json:"nullable"`
Default string `json:"default"`
}
ColumnInfo contains information about a table column
type DatabaseClient ¶
type DatabaseClient interface {
Query(ctx context.Context, sql string, args ...interface{}) (*QueryResult, error)
Transaction(ctx context.Context, queries []string) error
CreateTable(ctx context.Context, schema string) error
DropTable(ctx context.Context, tableName string) error
GetSchema(ctx context.Context) (*SchemaInfo, error)
}
DatabaseClient provides database operations for applications
type DatabaseClientImpl ¶
type DatabaseClientImpl struct {
// contains filtered or unexported fields
}
DatabaseClientImpl implements DatabaseClient
func (*DatabaseClientImpl) CreateTable ¶
func (d *DatabaseClientImpl) CreateTable(ctx context.Context, schema string) error
CreateTable creates a new table
func (*DatabaseClientImpl) DropTable ¶
func (d *DatabaseClientImpl) DropTable(ctx context.Context, tableName string) error
DropTable drops a table
func (*DatabaseClientImpl) GetSchema ¶
func (d *DatabaseClientImpl) GetSchema(ctx context.Context) (*SchemaInfo, error)
GetSchema returns schema information
func (*DatabaseClientImpl) Query ¶
func (d *DatabaseClientImpl) Query(ctx context.Context, sql string, args ...interface{}) (*QueryResult, error)
Query executes a SQL query
func (*DatabaseClientImpl) Transaction ¶
func (d *DatabaseClientImpl) Transaction(ctx context.Context, queries []string) error
Transaction executes multiple queries in a transaction
type HealthStatus ¶
type HealthStatus struct {
Status string `json:"status"` // "healthy", "degraded", "unhealthy"
Checks map[string]string `json:"checks"`
LastUpdated time.Time `json:"last_updated"`
ResponseTime time.Duration `json:"response_time"`
}
HealthStatus contains health check information
type MessageHandler ¶
MessageHandler is called when a pub/sub message is received
type NetworkClient ¶
type NetworkClient interface {
// Database operations (namespaced per app)
Database() DatabaseClient
// Pub/Sub messaging
PubSub() PubSubClient
// Network information
Network() NetworkInfo
// Storage operations (IPFS)
Storage() StorageClient
// Lifecycle
Connect() error
Disconnect() error
Health() (*HealthStatus, error)
// Config access (snapshot copy)
Config() *ClientConfig
}
NetworkClient provides the main interface for applications to interact with the network
func NewClient ¶
func NewClient(config *ClientConfig) (NetworkClient, error)
NewClient creates a new network client
type NetworkInfo ¶
type NetworkInfo interface {
GetPeers(ctx context.Context) ([]PeerInfo, error)
GetStatus(ctx context.Context) (*NetworkStatus, error)
ConnectToPeer(ctx context.Context, peerAddr string) error
DisconnectFromPeer(ctx context.Context, peerID string) error
}
NetworkInfo provides network status and peer information
type NetworkInfoImpl ¶
type NetworkInfoImpl struct {
// contains filtered or unexported fields
}
NetworkInfoImpl implements NetworkInfo
func (*NetworkInfoImpl) ConnectToPeer ¶
func (n *NetworkInfoImpl) ConnectToPeer(ctx context.Context, peerAddr string) error
ConnectToPeer connects to a specific peer
func (*NetworkInfoImpl) DisconnectFromPeer ¶
func (n *NetworkInfoImpl) DisconnectFromPeer(ctx context.Context, peerID string) error
DisconnectFromPeer disconnects from a specific peer
func (*NetworkInfoImpl) GetPeers ¶
func (n *NetworkInfoImpl) GetPeers(ctx context.Context) ([]PeerInfo, error)
GetPeers returns information about connected peers
func (*NetworkInfoImpl) GetStatus ¶
func (n *NetworkInfoImpl) GetStatus(ctx context.Context) (*NetworkStatus, error)
GetStatus returns network status
type NetworkStatus ¶
type NetworkStatus struct {
NodeID string `json:"node_id"`
Connected bool `json:"connected"`
PeerCount int `json:"peer_count"`
DatabaseSize int64 `json:"database_size"`
Uptime time.Duration `json:"uptime"`
}
NetworkStatus contains overall network status
type PeerInfo ¶
type PeerInfo struct {
ID string `json:"id"`
Addresses []string `json:"addresses"`
Connected bool `json:"connected"`
LastSeen time.Time `json:"last_seen"`
}
PeerInfo contains information about a network peer
type PubSubClient ¶
type PubSubClient interface {
Subscribe(ctx context.Context, topic string, handler MessageHandler) error
Publish(ctx context.Context, topic string, data []byte) error
Unsubscribe(ctx context.Context, topic string) error
ListTopics(ctx context.Context) ([]string, error)
}
PubSubClient provides publish/subscribe messaging
type QueryResult ¶
type QueryResult struct {
Columns []string `json:"columns"`
Rows [][]interface{} `json:"rows"`
Count int64 `json:"count"`
}
QueryResult represents the result of a database query
type SchemaInfo ¶
type SchemaInfo struct {
Tables []TableInfo `json:"tables"`
}
SchemaInfo contains database schema information
type StorageClient ¶ added in v0.69.13
type StorageClient interface {
// Upload uploads content to IPFS and pins it
Upload(ctx context.Context, reader io.Reader, name string) (*StorageUploadResult, error)
// Pin pins an existing CID
Pin(ctx context.Context, cid string, name string) (*StoragePinResult, error)
// Status gets the pin status for a CID
Status(ctx context.Context, cid string) (*StorageStatus, error)
// Get retrieves content from IPFS by CID
Get(ctx context.Context, cid string) (io.ReadCloser, error)
// Unpin removes a pin from a CID
Unpin(ctx context.Context, cid string) error
}
StorageClient provides IPFS storage operations
type StorageClientImpl ¶ added in v0.69.13
type StorageClientImpl struct {
// contains filtered or unexported fields
}
StorageClientImpl implements StorageClient using HTTP requests to the gateway
func (*StorageClientImpl) Get ¶ added in v0.69.13
func (s *StorageClientImpl) Get(ctx context.Context, cid string) (io.ReadCloser, error)
Get retrieves content from IPFS by CID
func (*StorageClientImpl) Pin ¶ added in v0.69.13
func (s *StorageClientImpl) Pin(ctx context.Context, cid string, name string) (*StoragePinResult, error)
Pin pins an existing CID
func (*StorageClientImpl) Status ¶ added in v0.69.13
func (s *StorageClientImpl) Status(ctx context.Context, cid string) (*StorageStatus, error)
Status gets the pin status for a CID
func (*StorageClientImpl) Unpin ¶ added in v0.69.13
func (s *StorageClientImpl) Unpin(ctx context.Context, cid string) error
Unpin removes a pin from a CID
func (*StorageClientImpl) Upload ¶ added in v0.69.13
func (s *StorageClientImpl) Upload(ctx context.Context, reader io.Reader, name string) (*StorageUploadResult, error)
Upload uploads content to IPFS and pins it
type StoragePinResult ¶ added in v0.69.13
StoragePinResult represents the result of pinning a CID
type StorageStatus ¶ added in v0.69.13
type StorageStatus struct {
Cid string `json:"cid"`
Name string `json:"name"`
Status string `json:"status"` // "pinned", "pinning", "queued", "unpinned", "error"
ReplicationMin int `json:"replication_min"`
ReplicationMax int `json:"replication_max"`
ReplicationFactor int `json:"replication_factor"`
Peers []string `json:"peers"`
Error string `json:"error,omitempty"`
}
StorageStatus represents the status of a pinned CID
type StorageUploadResult ¶ added in v0.69.13
type StorageUploadResult struct {
Cid string `json:"cid"`
Name string `json:"name"`
Size int64 `json:"size"`
}
StorageUploadResult represents the result of uploading content to IPFS
type TableInfo ¶
type TableInfo struct {
Name string `json:"name"`
Columns []ColumnInfo `json:"columns"`
}
TableInfo contains information about a database table