unicast

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 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 objects to overlay hosts one by one, for a deployment with no multicast plane (spec section 13).

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 "took" an object when its answer admits outputs for the topic, or when a lookup at that host answers the object. 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), so an answer that admits nothing is confirmed by lookup before it 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. bcommon's producer.Trees publishes each funding tree it adopts through one facade, and a bsecret funding tree is never published to a crypt on its own (spec section 12.4): every carrier, and a vault's first token, carries its own.

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) 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 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 publisher submits to.

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