Documentation
¶
Overview ¶
Package sync implements the sync server.
Index ¶
- type EnvelopeSink
- type MigrationConfig
- type NodeRegistration
- type NodeRegistryWatcher
- type SyncServer
- type SyncServerConfig
- type SyncServerOption
- func WithContext(ctx context.Context) SyncServerOption
- func WithDB(db *sql.DB) SyncServerOption
- func WithFeeCalculator(calc fees.IFeeCalculator) SyncServerOption
- func WithLogger(logger *zap.Logger) SyncServerOption
- func WithMigration(migration MigrationConfig) SyncServerOption
- func WithNodeRegistry(reg registry.NodeRegistry) SyncServerOption
- func WithPayerReportDomainSeparator(domainSeparator common.Hash) SyncServerOption
- func WithPayerReportStore(store payerreport.IPayerReportStore) SyncServerOption
- func WithRegistrant(r *registrant.Registrant) SyncServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnvelopeSink ¶ added in v0.5.0
type EnvelopeSink struct {
// contains filtered or unexported fields
}
func (*EnvelopeSink) Start ¶ added in v0.5.0
func (s *EnvelopeSink) Start()
type MigrationConfig ¶ added in v0.5.1
type NodeRegistration ¶ added in v0.1.1
type NodeRegistration struct {
// contains filtered or unexported fields
}
type NodeRegistryWatcher ¶ added in v0.5.0
type NodeRegistryWatcher struct {
// contains filtered or unexported fields
}
NodeRegistryWatcher monitors registry updates for a specific node and invokes a user-provided cancel function when a change is detected.
The cancel function is intended to trigger teardown or reinitialization of any state associated with that node (e.g., gRPC connections, sync loops).
📌 Usage:
watcher := NewNodeRegistryWatcher(ctx, log, nodeID, registry)
watcher.RegisterCancelFunction(func() {
teardownOrRestart()
})
watcher.Watch()
When the registry signals a change, the cancel function is invoked **exactly once**. If the caller wishes to handle **subsequent changes**, they must call `RegisterCancelFunction` again after each invocation.
If no cancel function is registered when a change occurs, the update is silently ignored.
func NewNodeRegistryWatcher ¶ added in v0.5.0
func NewNodeRegistryWatcher( ctx context.Context, logger *zap.Logger, nodeID uint32, nodeRegistry registry.NodeRegistry, ) *NodeRegistryWatcher
NewNodeRegistryWatcher creates a new watcher tied to the provided node ID. It does not begin watching until Watch() is explicitly called.
func (*NodeRegistryWatcher) RegisterCancelFunction ¶ added in v0.5.0
func (w *NodeRegistryWatcher) RegisterCancelFunction(fn func())
RegisterCancelFunction registers a cancel function to be invoked on the next registry update or shutdown event.
❗️Important: This function is called **once**, and then cleared. To respond to subsequent changes, you must register a new cancel function after each call.
func (*NodeRegistryWatcher) Watch ¶ added in v0.5.0
func (w *NodeRegistryWatcher) Watch()
Watch starts a background goroutine to listen for registry changes for the node. It invokes the registered cancel function (if present) once per change.
The watcher exits when:
- The parent context is cancelled
- The registry channel is closed
⚠️ Note: If no cancel function is registered when a change is detected, the update is **ignored**.
type SyncServer ¶
type SyncServer struct {
// contains filtered or unexported fields
}
func NewSyncServer ¶
func NewSyncServer(opts ...SyncServerOption) (*SyncServer, error)
func (*SyncServer) Close ¶
func (s *SyncServer) Close()
type SyncServerConfig ¶ added in v0.4.0
type SyncServerConfig struct {
Ctx context.Context
Logger *zap.Logger
NodeRegistry registry.NodeRegistry
Registrant *registrant.Registrant
DB *sql.DB
FeeCalculator fees.IFeeCalculator
PayerReportStore payerreport.IPayerReportStore
PayerReportDomainSeparator common.Hash
Migration MigrationConfig
}
type SyncServerOption ¶ added in v0.4.0
type SyncServerOption func(*SyncServerConfig)
func WithContext ¶ added in v0.4.0
func WithContext(ctx context.Context) SyncServerOption
func WithDB ¶ added in v0.4.0
func WithDB(db *sql.DB) SyncServerOption
func WithFeeCalculator ¶ added in v0.4.0
func WithFeeCalculator(calc fees.IFeeCalculator) SyncServerOption
func WithLogger ¶ added in v0.4.0
func WithLogger(logger *zap.Logger) SyncServerOption
func WithMigration ¶ added in v0.5.1
func WithMigration(migration MigrationConfig) SyncServerOption
func WithNodeRegistry ¶ added in v0.4.0
func WithNodeRegistry(reg registry.NodeRegistry) SyncServerOption
func WithPayerReportDomainSeparator ¶ added in v0.5.0
func WithPayerReportDomainSeparator(domainSeparator common.Hash) SyncServerOption
func WithPayerReportStore ¶ added in v0.5.0
func WithPayerReportStore(store payerreport.IPayerReportStore) SyncServerOption
func WithRegistrant ¶ added in v0.4.0
func WithRegistrant(r *registrant.Registrant) SyncServerOption