broadcast

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package broadcast implements a MCollective like broadcast discovery system for nodes running choria

It is not thread safe and a single instance of the discoverer shouldn't be shared by go routines etc, you can reuse them but should not be using the same one multiple times.

It will create a single connection to your Choria network and close it once the context to Discover is canceled.

It has been shown to discover 50 000 nodes in around 1.2 seconds, I'd suggest on such a large network setting protocol.ClientStrictValidation to false

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcast

type Broadcast struct {
	// contains filtered or unexported fields
}

Broadcast implements mcollective like broadcast discovery

func New

func New(fw inter.Framework) *Broadcast

New creates a new broadcast discovery client

func (*Broadcast) Discover

func (b *Broadcast) Discover(ctx context.Context, opts ...DiscoverOption) (n []string, err error)

Discover performs a broadcast discovery using the supplied filter

type ChoriaClient

type ChoriaClient interface {
	Request(ctx context.Context, msg inter.Message, handler client.Handler) (err error)
}

ChoriaClient implements the connection to the Choria network

type DiscoverOption

type DiscoverOption func(o *dOpts)

DiscoverOption configures the broadcast discovery method

func Collective

func Collective(c string) DiscoverOption

Collective sets the collective to discover in, else main collective is used

func Filter

func Filter(f *protocol.Filter) DiscoverOption

Filter sets the filter to use for the discovery, else a blank one is used

func Name

func Name(n string) DiscoverOption

Name sets a NATS connection name to use, without this random names will be made.

This setting is important if you make a daemon that makes many long client connections as each client connection makes Prometheus stats based on the name and you'll be leaking many stats over time

func SlidingWindow added in v0.24.0

func SlidingWindow() DiscoverOption

SlidingWindow enables a sliding window for discovery timeout that terminates discovery after 300ms of no responses

func Timeout

func Timeout(t time.Duration) DiscoverOption

Timeout sets the discovery timeout, else the configured default is used

Jump to

Keyboard shortcuts

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