topofetcher

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacks

type Callbacks struct {
	// Raw is called with the raw body from the discovery service response and the parsed topology.
	Raw func(context.Context, common.RawBytes, *topology.Topo)
	// Update is called with the parsed topology from the discovery service response.
	Update func(context.Context, *topology.Topo)
	// Error is called with any error that occurs.
	Error func(context.Context, error)
}

Callbacks are used to inform the client. The functions are called when an associated event occurs. If the function is nil, it is ignored.

type Fetcher

type Fetcher struct {
	// Pool is a Pool of discovery services
	Pool discovery.InstancePool
	// Params contains the parameters for fetching the topology.
	Params discovery.FetchParams
	// Callbacks contains the callbacks.
	Callbacks Callbacks
	// Client is the http Client. If nil, the default Client is used.
	Client *http.Client
	// contains filtered or unexported fields
}

Fetcher is used to fetch a new topology file from the discovery service.

func New

func New(svcInfo topology.IDAddrMap, params discovery.FetchParams,
	clbks Callbacks, client *http.Client, component string) (*Fetcher, error)

New initializes a fetcher with the given values. Topo is provided to initialize the pool with discovery services.

func (*Fetcher) Name

func (f *Fetcher) Name() string

Name returns the tasks name.

func (*Fetcher) Run

func (f *Fetcher) Run(ctx context.Context)

Run fetches a new topology file from the discovery service and calls the appropriate callback functions to notify the caller. RawF and UpdateF are only called if no error has occurred and the topology was parsed correctly. Otherwise ErrorF is called.

func (*Fetcher) UpdateInstances

func (f *Fetcher) UpdateInstances(svcInfo topology.IDAddrMap) error

UpdateInstances updates the discovery service pool.

Jump to

Keyboard shortcuts

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