unicast

package
v0.1.2 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

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

On the plane a producer submits each object once, to one facade, and the plane delivers it to every host subscribed to the topic and repairs what is lost on the way. Without the plane the producer does that itself: a Set submits every object to each of its hosts individually, retries each host on its own, and reports each host's answer. The object counts as published when at least Need hosts took it. A host that missed it does not receive it from the others; blogs backfill copies it across later.

"Took it" means the host answered the submit with 200 and a STEAK for the topic. A host that answers with nothing admitted has decided (it holds the object already, or its topic manager refused it); resending cannot change that, so it is reported and counted as an answer, never retried.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 publish.Result for callers that expect a single host's answer: the first host that admitted something, else the first that answered. Duplicate is then true only when no host admitted anything.

func (Outcome) OK

func (o Outcome) OK() bool

OK reports whether enough hosts answered.

func (Outcome) Took

func (o Outcome) Took() int

Took is how many hosts answered.

type Result

type Result struct {
	Host string
	// Result is the host's STEAK entry when Err is nil.
	Result publish.Result
	// Err is the last failure when every try failed.
	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 answered.

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 Submit to succeed.
	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 bcommon'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 producer submits to.

func (*Set) Facade

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

Facade is a publish.Facade whose every Submit is a Send to the whole Set with the Set's quorum, for code that takes one facade (bcommon's producer.Trees publishes each funding tree it adopts through one). Its base URL is never dialled: its transport answers every request itself. what names the objects it carries in notes.

func (*Set) Send

func (s *Set) Send(ctx context.Context, what, topic string, beef []byte, need int) 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.

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 answered and did not.
	Took, Missed int
	// MissedWhat names the missed objects, in order, as Send was told.
	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