Help us shape the future of Go! Take the 2026 Go Developer Survey

cluster

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashToken

func HashToken(token string) string

Types

type AggregatedResponse

type AggregatedResponse struct {
	Servers map[string]ServerResult `json:"servers"`
}

func AggregateFromPeers

func AggregateFromPeers(ctx context.Context, localData []byte, mgr *Manager, path string) *AggregatedResponse

type Client

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

func NewClient

func NewClient(baseURL, apiKey string, timeout time.Duration) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)

func (*Client) Forward

func (c *Client) Forward(ctx context.Context, method, path string, body io.Reader) ([]byte, int, map[string]string, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) ([]byte, int, error)

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body []byte) ([]byte, int, error)

type DB

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

func NewDB

func NewDB(deploymentsPath string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) ConsumeInvite

func (db *DB) ConsumeInvite(tokenHash string, peerName string) error

func (*DB) CreateInvite

func (db *DB) CreateInvite(invite *Invite) (int64, error)

func (*DB) CreatePeer

func (db *DB) CreatePeer(peer *Peer) (int64, error)

func (*DB) DeletePeer

func (db *DB) DeletePeer(name string) error

func (*DB) GetInviteByHash

func (db *DB) GetInviteByHash(tokenHash string) (*Invite, error)

func (*DB) GetPeer

func (db *DB) GetPeer(name string) (*Peer, error)

func (*DB) ListPeers

func (db *DB) ListPeers() ([]Peer, error)

func (*DB) UpdateLastSeen

func (db *DB) UpdateLastSeen(name string) error

type Invite

type Invite struct {
	ID           int64     `json:"id"`
	TokenHash    string    `json:"-"`
	Status       string    `json:"status"`
	CreatedBy    int64     `json:"created_by"`
	AcceptedPeer string    `json:"accepted_peer,omitempty"`
	ExpiresAt    time.Time `json:"expires_at"`
	CreatedAt    time.Time `json:"created_at"`
}

type Manager

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

func NewManager

func NewManager(db *DB, serverName string, healthInterval, requestTimeout time.Duration, jwtSecret string) *Manager

func (*Manager) AddPeer

func (m *Manager) AddPeer(name, url, apiKey string) error

func (*Manager) DB

func (m *Manager) DB() *DB

func (*Manager) ForEachPeer

func (m *Manager) ForEachPeer(ctx context.Context, fn func(ctx context.Context, name string, client *Client) ([]byte, error)) map[string]Result

func (*Manager) GetPeer

func (m *Manager) GetPeer(name string) (*Client, error)

func (*Manager) ListPeers

func (m *Manager) ListPeers() []PeerStatus

func (*Manager) RemovePeer

func (m *Manager) RemovePeer(name string) error

func (*Manager) ServerName

func (m *Manager) ServerName() string

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

func (*Manager) Stop

func (m *Manager) Stop()

type Peer

type Peer struct {
	ID              int64     `json:"id"`
	Name            string    `json:"name"`
	URL             string    `json:"url"`
	APIKeyHash      string    `json:"-"`
	APIKeyEncrypted string    `json:"-"`
	Status          string    `json:"status"`
	CreatedAt       time.Time `json:"created_at"`
	LastSeenAt      time.Time `json:"last_seen_at,omitempty"`
}

type PeerStatus

type PeerStatus struct {
	Name     string    `json:"name"`
	URL      string    `json:"url"`
	Online   bool      `json:"online"`
	LastSeen time.Time `json:"last_seen"`
	Error    string    `json:"error,omitempty"`
}

type Result

type Result struct {
	Data  []byte `json:"data,omitempty"`
	Error string `json:"error,omitempty"`
}

type ServerResult

type ServerResult struct {
	Name   string          `json:"name"`
	Online bool            `json:"online"`
	Data   json.RawMessage `json:"data,omitempty"`
	Error  string          `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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