serverfunk

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package serverfunk contains types that comes in handy when writing servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithClusterFunk

func WithClusterFunk(cluster funk.Cluster, shardFn ShardConversionFunc, clientProxy *ProxyConnections, metricsType string) []grpc.ServerOption

WithClusterFunk returns server options for Clusterfunk gRPC servers. This will add a stream and unary interceptor to the server that will proxy the requests to the correct peer. The metrics string is the one used in the Parameters struct from the funk package. Streams are not proxied.

Types

type ProxyConnections

type ProxyConnections struct {
	Shards       sharding.ShardMap
	Cluster      funk.Cluster
	EndpointName string
	// contains filtered or unexported fields
}

ProxyConnections manages grpc.ClientConn connections to proxies.

func NewProxyConnections

func NewProxyConnections(endpointName string, shards sharding.ShardMap, cluster funk.Cluster) *ProxyConnections

NewProxyConnections creates a new GRPCClientProxy

func (*ProxyConnections) GetConnection

func (p *ProxyConnections) GetConnection(shard int) (*grpc.ClientConn, string, error)

GetConnection returns a gRPC connection and node ID to the service handling the shard (ID). If the shard is handled locally it will return a nil connection

func (*ProxyConnections) Options

func (p *ProxyConnections) Options() []grpc.DialOption

Options returns the grpc.DialOption to use when creating new connections

type ShardConversionFunc

type ShardConversionFunc func(request interface{}) (shard int, response interface{})

ShardConversionFunc is the shard conversion function, ie return a shard based on the request parameter to the gRPC server methods. It will also return the expected response object for the request. This *does* require a un

Jump to

Keyboard shortcuts

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