Documentation
¶
Index ¶
- func New(config ...*Config) fiber.Handler
- type Config
- func (c *Config) Validate() *Config
- func (c *Config) WithBufferSize(size int) *Config
- func (c *Config) WithCompression(enabled bool) *Config
- func (c *Config) WithDataReplication(config DataReplicationConfig) *Config
- func (c *Config) WithDebug(enabled bool) *Config
- func (c *Config) WithHeartbeat(interval time.Duration) *Config
- func (c *Config) WithTimeout(timeout time.Duration) *Config
- type DataReplicationConfig
- type GunDB
- type GunGet
- type GunMessage
- type GunOk
- type GunPut
- type PeerConnection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Next defines a function to skip this middleware when returned true
Next func(c *fiber.Ctx) bool
// WebSocketEndpoint is the endpoint where GunDB websocket connections will be handled
WebSocketEndpoint string
// StaticPath is the path to serve the GunDB client files
StaticPath string
// HeartbeatInterval is the interval for sending heartbeat pings
HeartbeatInterval time.Duration
// PeerTimeout is the duration after which a peer is considered inactive
PeerTimeout time.Duration
// MaxMessageSize is the maximum size of a WebSocket message in bytes
MaxMessageSize int64
// EnableCompression enables WebSocket compression
EnableCompression bool
// BufferSize sets the read/write buffer size for WebSocket connections
BufferSize int
// Debug enables detailed logging
Debug bool
// ReconnectAttempts is the number of times to attempt reconnection
ReconnectAttempts int
// ReconnectInterval is the time to wait between reconnection attempts
ReconnectInterval time.Duration
// DataReplication configures how data is replicated between peers
DataReplication DataReplicationConfig
// contains filtered or unexported fields
}
Config defines the config for GunDB middleware
func ConfigDefault ¶
func ConfigDefault() *Config
func (*Config) WithBufferSize ¶
WithBufferSize sets the WebSocket buffer size
func (*Config) WithCompression ¶
WithCompression enables or disables WebSocket compression
func (*Config) WithDataReplication ¶
func (c *Config) WithDataReplication(config DataReplicationConfig) *Config
WithDataReplication configures data replication
func (*Config) WithHeartbeat ¶
WithHeartbeat sets the heartbeat interval
type DataReplicationConfig ¶
type DataReplicationConfig struct {
// Enabled determines if data should be replicated between peers
Enabled bool
// SyncInterval is how often to sync data between peers
SyncInterval time.Duration
// MaxRetries is the maximum number of sync retries
MaxRetries int
// BatchSize is the maximum number of items to sync at once
BatchSize int
}
DataReplicationConfig defines how data is replicated between peers
type GunDB ¶
type GunDB struct {
// contains filtered or unexported fields
}
GunDB represents the main handler structure
type GunGet ¶
type GunGet struct {
Hash string `json:"#,omitempty"`
Key string `json:".,omitempty"`
Soul string `json:"#,omitempty"`
}
GunGet represents a GET request in GunDB
type GunMessage ¶
type GunMessage struct {
Get *GunGet `json:"get,omitempty"`
Put *GunPut `json:"put,omitempty"`
Hash string `json:"#,omitempty"`
Ok *GunOk `json:"ok,omitempty"`
Err string `json:"err,omitempty"`
}
GunMessage represents various GunDB message types
type GunOk ¶
type GunOk struct {
Hash string `json:"@,omitempty"`
Data map[string]interface{} `json:"/,omitempty"`
}
GunOk represents an acknowledgment in GunDB
Click to show internal directories.
Click to hide internal directories.