entanglement

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 13 Imported by: ? 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.

README

entanglement

Mesh communication library for go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entanglement

type Entanglement[THash comparable] struct {
	// contains filtered or unexported fields
}

Entanglement broadcasts messages between peers.

func New

func New[THash comparable](
	peerCh <-chan PeerIO,
	sendCh <-chan []byte,
	hashingFunc HashingFunc[THash],
	msgHandler HandlerFunc[THash],
) *Entanglement[THash]

New creates new entanglement.

func (*Entanglement[THash]) ClearCache

func (e *Entanglement[THash]) ClearCache(hash THash)

ClearCache removes hash from the deduplication cache.

func (*Entanglement[THash]) Run

func (e *Entanglement[THash]) Run(ctx context.Context) error

Run runs the entanglement.

type HandlerFunc added in v0.2.0

type HandlerFunc[THash comparable] func(ctx context.Context, msg []byte, hash THash) error

HandlerFunc defines the function handling received messages.

type HashingFunc added in v0.2.0

type HashingFunc[THash comparable] func(msg []byte) THash

HashingFunc computes hash of the message.

type PeerIO

type PeerIO interface {
	io.Closer
	io.Reader
	io.Writer
	io.ByteReader
}

PeerIO specifies the interface required from connected peers.

Jump to

Keyboard shortcuts

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