grpc

package
v0.58.13 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: Unlicense Imports: 9 Imported by: 0

Documentation

Overview

Package grpc provides a gRPC client for the negentropy sync service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a gRPC client for the negentropy sync service.

func New

func New(ctx context.Context, cfg *ClientConfig) (*Client, error)

New creates a new gRPC negentropy sync client.

func (*Client) AddPeer

func (c *Client) AddPeer(ctx context.Context, peerURL string) error

AddPeer adds a peer for negentropy sync.

func (*Client) Close

func (c *Client) Close() error

Close closes the gRPC connection.

func (*Client) CloseSession

func (c *Client) CloseSession(ctx context.Context, connectionID, subscriptionID string) error

CloseSession forcefully closes a client session.

func (*Client) GetPeerSyncState

func (c *Client) GetPeerSyncState(ctx context.Context, peerURL string) (*PeerSyncState, bool, error)

GetPeerSyncState returns sync state for a specific peer.

func (*Client) GetPeers

func (c *Client) GetPeers(ctx context.Context) ([]string, error)

GetPeers returns the list of negentropy sync peers.

func (*Client) GetSyncStatus

func (c *Client) GetSyncStatus(ctx context.Context) (*SyncStatus, error)

GetSyncStatus returns the current sync status.

func (*Client) HandleNegClose

func (c *Client) HandleNegClose(ctx context.Context, connectionID, subscriptionID string) error

HandleNegClose processes a NEG-CLOSE message from a client.

func (*Client) HandleNegMsg

func (c *Client) HandleNegMsg(ctx context.Context, connectionID, subscriptionID string, message []byte) ([]byte, [][]byte, [][]byte, bool, string, error)

HandleNegMsg processes a NEG-MSG message from a client.

func (*Client) HandleNegOpen

func (c *Client) HandleNegOpen(ctx context.Context, connectionID, subscriptionID string, filter *commonv1.Filter, initialMessage []byte) ([]byte, [][]byte, [][]byte, bool, string, error)

HandleNegOpen processes a NEG-OPEN message from a client. Returns: message, haveIDs, needIDs, complete, errorStr, error

func (*Client) ListSessions

func (c *Client) ListSessions(ctx context.Context) ([]*negentropyiface.ClientSession, error)

ListSessions returns active client negentropy sessions.

func (*Client) Ready

func (c *Client) Ready() <-chan struct{}

Ready returns a channel that closes when the client is ready.

func (*Client) RemovePeer

func (c *Client) RemovePeer(ctx context.Context, peerURL string) error

RemovePeer removes a peer from negentropy sync.

func (*Client) Start

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

Start starts the background relay-to-relay sync.

func (*Client) Stop

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

Stop stops the background sync.

func (*Client) SyncWithPeer

func (c *Client) SyncWithPeer(ctx context.Context, peerURL string, filter *commonv1.Filter, since int64) (<-chan *SyncProgress, error)

SyncWithPeer initiates negentropy sync with a specific peer relay. Returns a channel that receives progress updates.

func (*Client) TriggerSync

func (c *Client) TriggerSync(ctx context.Context, peerURL string, filter *commonv1.Filter) error

TriggerSync manually triggers sync with a specific peer or all peers.

type ClientConfig

type ClientConfig struct {
	ServerAddress  string
	ConnectTimeout time.Duration
}

ClientConfig holds configuration for the gRPC client.

type PeerSyncState

type PeerSyncState struct {
	PeerURL             string
	LastSync            int64
	EventsSynced        int64
	Status              string
	LastError           string
	ConsecutiveFailures int32
}

PeerSyncState represents sync state for a peer.

type SyncProgress

type SyncProgress struct {
	PeerURL      string
	Round        int32
	HaveCount    int64
	NeedCount    int64
	FetchedCount int64
	SentCount    int64
	Complete     bool
	Error        string
}

SyncProgress represents progress during a peer sync operation.

type SyncStatus

type SyncStatus struct {
	Active     bool
	LastSync   int64
	PeerCount  int32
	PeerStates []*PeerSyncState
}

SyncStatus represents the sync status response.

Jump to

Keyboard shortcuts

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