flashlight

package module
v0.0.0-...-3e4e20d Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: MIT Imports: 3 Imported by: 0

README

Flashlight

Build Status Code Coverage Latest Version GoDoc Go Report Card

Flashlight is an abstraction for discovering gRPC servers and services in Go.

Documentation

Overview

Package flashlight contains tools for discovering gRPC servers and services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetaData

type MetaData map[interface{}]interface{}

MetaData is a container for meta-data about a target.

type Target

type Target struct {
	// Group is a driver-defined identifier for a group of targets.
	//
	// Targets within the same (non-empty) group are considered interchangeable.
	Group string

	// Name is the target name used to dial the endpoint. The syntax is defined
	// in https://github.com/grpc/grpc/blob/master/doc/naming.md.
	Name string

	// Options is a set of grpc.DialOptions used when dialing this target.
	// The options must not include grpc.WithBlock().
	Options []grpc.DialOption

	// MetaData contains driver-specific meta-data about the target.
	MetaData MetaData
}

Target represents some dialable gRPC target, typically a single gRPC server.

type TargetObserver

type TargetObserver interface {
	// TargetAdded is called when a target is added to an observed registry.
	TargetAdded(*Target)

	// TargetRemoved is called when a target is removed from an observed
	// registry.
	TargetRemoved(*Target)
}

A TargetObserver is notified when targets are added or removed from a TargetRegistry.

type TargetRegistry

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

TargetRegistry is a container for discovered gRPC servers.

func (*TargetRegistry) Add

func (r *TargetRegistry) Add(t *Target)

Add adds a target to the registry.

func (*TargetRegistry) Has

func (r *TargetRegistry) Has(t *Target) bool

Has returns true if t is in the registry.

func (*TargetRegistry) Range

func (r *TargetRegistry) Range(fn func(*Target) bool) bool

Range invokes fn once for each target in the registry.

Iteration stops when fn returns false or once fn has been invoked for all targets in the registry.

It returns true if fn returned true for all targets.

func (*TargetRegistry) RegisterObserver

func (r *TargetRegistry) RegisterObserver(o TargetObserver)

RegisterObserver registers o to be notified when targets are added to and removed from the registry.

o.TargetAdded() is immediately called for each target in the registry.

func (*TargetRegistry) Remove

func (r *TargetRegistry) Remove(t *Target)

Remove removes a target from the registry.

func (*TargetRegistry) Select

func (r *TargetRegistry) Select(g string) (t *Target, ok bool)

Select returns a random target from the given group.

If there are no targets in the given group, ok is false.

func (*TargetRegistry) UnregisterObserver

func (r *TargetRegistry) UnregisterObserver(o TargetObserver)

UnregisterObserver stops o from being notified when targets are added to or removed from the registry in the future.

o.TargetRemoved() is immediately called for each target in the registry.

Directories

Path Synopsis
cmd
Package dockerswarm discovers gRPC targets by inspecting Docker services.
Package dockerswarm discovers gRPC targets by inspecting Docker services.
internal

Jump to

Keyboard shortcuts

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