sync

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrentRequest

type CurrentRequest struct {
	NodeID   string `json:"node_id"`
	RelayURL string `json:"relay_url"`
}

CurrentRequest represents a request for the current serial number

type CurrentResponse

type CurrentResponse struct {
	NodeID   string `json:"node_id"`
	RelayURL string `json:"relay_url"`
	Serial   uint64 `json:"serial"`
}

CurrentResponse returns the current serial number

type FetchRequest

type FetchRequest struct {
	NodeID   string `json:"node_id"`
	RelayURL string `json:"relay_url"`
	From     uint64 `json:"from"`
	To       uint64 `json:"to"`
}

FetchRequest represents a request for events in a serial range

type FetchResponse

type FetchResponse struct {
	Events []string `json:"events"` // JSONL formatted events
}

FetchResponse contains the requested events as JSONL

type Manager

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

Manager handles distributed synchronization between relay peers using serial numbers as clocks

func NewManager

func NewManager(ctx context.Context, db *database.D, nodeID, relayURL string, peers []string) *Manager

NewManager creates a new sync manager

func (*Manager) GetCurrentSerial

func (m *Manager) GetCurrentSerial() uint64

GetCurrentSerial returns the current serial number

func (*Manager) HandleCurrentRequest

func (m *Manager) HandleCurrentRequest(w http.ResponseWriter, r *http.Request)

HandleCurrentRequest handles requests for current serial number

func (*Manager) HandleFetchRequest

func (m *Manager) HandleFetchRequest(w http.ResponseWriter, r *http.Request)

HandleFetchRequest handles requests for events in a serial range

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops the sync manager

func (*Manager) UpdateSerial

func (m *Manager) UpdateSerial()

UpdateSerial updates the current serial number when a new event is stored

Source Files

  • manager.go

Jump to

Keyboard shortcuts

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