sinkserver

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sinkserver is the receiving side of the sink: the SinkService handler the writer mounts, and the Receiver that checks a caller and a batch before handing it to a Sink.

The client side, and the Sink interface both sides share, are in the SDK's sink package, which carries none of the server's dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(s sink.Sink, opts ...connect.HandlerOption) (string, http.Handler)

NewHandler returns the path and handler to mount.

Types

type Handler

type Handler struct {
	auditv1connect.UnimplementedSinkServiceHandler
	// contains filtered or unexported fields
}

Handler serves SinkService from a Sink, which is how the writer is reached by anything that cannot call it in process.

func (*Handler) Write

Write implements the service.

type Receiver

type Receiver struct {
	// To is the next hop, normally a stream publisher.
	To sink.Sink
	// Self names this receiver when a record arrives with no verified caller,
	// which is an in-process call or a trial install accepting anonymous
	// writes. Empty leaves the observer empty, which is what an anonymous
	// write means.
	Self string
	// Version and Instance name this build and this pod on the records it
	// stamps, where the emitter left them empty.
	Version  string
	Instance string
	// Now is the clock, for tests. Default time.Now.
	Now func() time.Time
}

Receiver is the front door of an installation that keeps its records on a stream: it stamps each record with the caller it verified and hands the batch to the next hop, which publishes it.

Stamping has to happen here. The consumer on the other side of a stream has no caller to verify — it is reading messages, not serving a request — so a record that reached the stream unstamped would be written with no observer at all, and the trail would not say who reported what. The writer on the far side keeps a stamp that verifies rather than replacing it, because it can only be reading its own installation's stream.

It is the same reasoning as everywhere else here: a reporter never says who it is. The identity comes from the token the authenticator checked, and the application cannot choose it.

func (*Receiver) Guarantees

func (r *Receiver) Guarantees() sink.Durability

Guarantees implements Guarantor: a receiver gives what its next hop gives.

func (*Receiver) Write

func (r *Receiver) Write(ctx context.Context, req *sink.Request) (*sink.Result, error)

Write stamps and forwards.

Jump to

Keyboard shortcuts

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