clientfunk

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package clientfunk contains client-side types and utilities

Index

Constants

View Source
const ClusterfunkSchemaName = "cluster"

ClusterfunkSchemaName is the schema used for the connections. Each server connection uses clusterfunk://[endpointname] when resolving. This should be combined with the service config settings included in this package.

View Source
const GRPCServiceConfig = `{
	"loadBalancingPolicy": "round_robin"
}`

GRPCServiceConfig is the default service config for Clusterfunk clients. It will enable retries when the service is down but not when the call times out.

Variables

This section is empty.

Functions

func AddClusterEndpoint

func AddClusterEndpoint(endpointName, endpoint string)

AddClusterEndpoint adds a single cluster endpoint to the collection used by the gRPC resolver. The same endpoint can be added multiple times.

func GetEndpoints

func GetEndpoints(name string, managementClientParam toolbox.GRPCClientParam) ([]string, error)

GetEndpoints returns the endpoints in the cluster. This method uses the gRPC management endpoint to query for endpoints.

func RemoveClusterEndpoint

func RemoveClusterEndpoint(endpointName, endpoint string)

RemoveClusterEndpoint removes a single cluster endpoint from the collection used by the gRPC resolver. All endpoints with the given name and endpoint will be removed from the collection.

func UpdateClusterEndpoints

func UpdateClusterEndpoints(endpointName string, endpoints []string)

UpdateClusterEndpoints updates all of the cluster endpoints with a given name. The existing cluster endpoints with that name is removed from the collection used by the gRPC resolver.

func ZeroconfManagementLookup

func ZeroconfManagementLookup(clusterName string) (string, error)

ZeroconfManagementLookup does a lookup in Zeroconf to find endpoints. The cluster nodes must have Zeroconf enabled for this to work

Types

type EndpointMonitor

type EndpointMonitor interface {
	// Stop halts the endpoint monitor and releases all of the resources
	Stop()

	// WaitForEndpoints waits for the first endpoint to be set.
	WaitForEndpoints()
}

EndpointMonitor monitors a Serf cluster for endpoint changes. Endpoints registered by servers with the Raft endpoint will be added to the gRPC endpoint list and used by the client. Note that the endpoints might not be valid at all times so errors may occur if the server is not yet a member of the cluster or simply unaavaible. Serf is more resilient to network partitions than Raft so a server might be in the Serf cluster while not a member of a quorum in Raft so the client should handle invalid endpoints gracefully.

func StartEndpointMonitor

func StartEndpointMonitor(clientName, clusterName string, zeroConf bool, serfParameters funk.SerfParameters) (EndpointMonitor, error)

StartEndpointMonitor monitors the Serf cluster for endpoints and updates the gRPC endpoint list continuously. The client will be a Serf not but not a member of the Raft cluster. The client name is optional. If it is empty a random client name will be set.

Jump to

Keyboard shortcuts

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