Help us shape the future of Go! Take the 2026 Go Developer Survey

unicast

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package unicast publishes objects to overlay hosts one by one, for a deployment with no multicast plane.

On the plane a publisher submits each object once, to one facade, and the plane delivers it to every subscribed host and repairs what is lost on the way. Without the plane the publisher does that itself: a Set submits every object to each of its hosts individually, retries each host on its own, and counts the object published once Need hosts took it. A host that missed it does not receive it from the others; the application's own fill or backfill copies it across later.

A host "took" an object when it answered the submit with 200 and a STEAK for the topic. To a submitter a duplicate and a refusal look the same (an answer that admits nothing: a topic manager raises a refusal, and the engine does not return it as an error). Without a Confirm such an answer counts as taken: resending cannot change it. With a Confirm the application asks the host whether it answers the object, and only a yes counts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Kept

func Kept() *publish.Facade

Kept is a publish.Facade that sends nothing: every Submit is answered with nothing admitted. producer.Trees publishes each funding tree it adopts through one facade; an application whose funding trees are never published on their own (every carrier carries its own) gives it this.

Types

type Confirm

type Confirm func(ctx context.Context, host string) (bool, error)

Confirm asks host whether it answers the object, for an answer that admitted nothing. Nil counts such an answer as taken.

type Outcome

type Outcome struct {
	What    string
	Results []Result
	Need    int
}

Outcome is every host's answer to one submit.

func (Outcome) Err

func (o Outcome) Err() error

Err is nil when the outcome is OK, and otherwise names every host that missed the object and why.

func (Outcome) Merged

func (o Outcome) Merged() publish.Result

Merged is one answer standing for every host's: the first that admitted outputs, else the first host's that answered at all, else the zero Result.

func (Outcome) Missed

func (o Outcome) Missed() []string

Missed are the hosts that did not take the object.

func (Outcome) OK

func (o Outcome) OK() bool

OK reports whether enough hosts took it.

func (Outcome) Took

func (o Outcome) Took() int

Took is how many hosts took the object.

type Result

type Result struct {
	Host string
	// Result is the host's STEAK entry when Err is nil.
	Result publish.Result
	// Confirmed is set when the answer admitted nothing and a lookup at
	// the host answers the object.
	Confirmed bool
	// Err is the last failure when every try failed, or why an answer that
	// admitted nothing was not confirmed.
	Err error
	// Tries is how many times the host was asked.
	Tries int
}

Result is one host's answer to one submit.

func (Result) Took

func (r Result) Took() bool

Took reports whether the host took the object.

type Set

type Set struct {
	// Hosts are the hosts' base URLs; each is POSTed <base>/submit.
	Hosts []string
	// Need is how many hosts must take an object for it to count.
	Need int
	// Retries are the waits between the tries of one host: a host is tried
	// 1+len(Retries) times before it is counted as missed.
	Retries []time.Duration
	// HTTP is the client each host's facade uses; nil is publish's default.
	HTTP *http.Client
	// Note receives a line per host that did not take an object, and with
	// Verbose a line per host that did.
	Note    func(format string, args ...any)
	Verbose bool
	// contains filtered or unexported fields
}

Set is the hosts a publisher submits to.

func (*Set) Facade

func (s *Set) Facade(what string) *publish.Facade

Facade is a publish.Facade that sends every Submit to each of the Set's hosts (Send, with no Confirm and the Set's quorum), for code that publishes through one facade, such as producer.Trees. Below the quorum it answers 502 naming the hosts that missed; otherwise the merged answer. what names the objects in notes and tallies.

func (*Set) Send

func (s *Set) Send(ctx context.Context, what, topic string, beef []byte, need int, confirm Confirm) Outcome

Send submits beef for topic to every host at once, each retried on its own, and returns every host's answer. what names the object in notes. need is the quorum for this object; zero means s.Need. confirm, when set, is asked about every host whose answer admitted nothing.

func (*Set) Tallies

func (s *Set) Tallies() []Tally

Tallies are the per-host counts so far, in Hosts order.

type Tally

type Tally struct {
	Host string
	// Took and Missed count the objects the host took and did not.
	Took, Missed int
	// MissedWhat names the missed objects, in order.
	MissedWhat []string
}

Tally is what one host was sent in this process's lifetime.

Jump to

Keyboard shortcuts

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