Documentation
¶
Overview ¶
Package writecoordinator serialises all SQLite write operations through a single goroutine, eliminating concurrent write contention on the primary instance and providing a natural chokepoint for metrics and backpressure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator serialises all write operations through a single background goroutine, satisfying the dbproxy.WriteSubmitter interface.
func New ¶
New creates a Coordinator and starts the serialisation goroutine. queueSize specifies the job-channel buffer; values <= 0 default to 256.
func (*Coordinator) Metrics ¶
func (c *Coordinator) Metrics() CoordinatorMetrics
Metrics returns a consistent snapshot of coordinator statistics.
func (*Coordinator) SetPublisher ¶
func (c *Coordinator) SetPublisher(pub changepub.Publisher)
SetPublisher attaches a change-event publisher to the coordinator. Must be called before the first Submit; not safe for concurrent use.
func (*Coordinator) Shutdown ¶
func (c *Coordinator) Shutdown()
Shutdown stops the coordinator gracefully. In-flight jobs that have already been dequeued will still complete; pending jobs that are still in the channel will have their callers unblocked via the done signal.
func (*Coordinator) Submit ¶
func (c *Coordinator) Submit(ctx context.Context, req dbproxy.WriteRequest) (json.RawMessage, error)
Submit enqueues a write job and blocks until the result is available or the caller's context is cancelled. It satisfies dbproxy.WriteSubmitter.
type CoordinatorMetrics ¶
type CoordinatorMetrics struct {
Accepted uint64
Completed uint64
Failed uint64
QueueDepth int
MaxQueue int
}
CoordinatorMetrics holds a consistent snapshot of coordinator statistics.
type WriteJob ¶
type WriteJob struct {
// contains filtered or unexported fields
}
WriteJob is a single write request queued for serialised execution.
type WriteResult ¶
type WriteResult struct {
Result json.RawMessage
Error error
}
WriteResult is the outcome of a serialised write operation.