broadcast

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2020 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package broadcast implements a MCollective like broadcast discovery system for nodes running choria - either Ruby or Go editions

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 NATS network and close it once the context to Discover is cancelled.

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

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 *choria.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 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