Documentation
¶
Index ¶
- Constants
- func NewGossipServiceHandler(svc GossipServiceHandler, opts ...connect.HandlerOption) (string, http.Handler)
- type GossipServiceClient
- type GossipServiceHandler
- type UnimplementedGossipServiceHandler
- func (UnimplementedGossipServiceHandler) IndirectPing(context.Context, *connect.Request[v1.IndirectPingRequest]) (*connect.Response[v1.IndirectPingResponse], error)
- func (UnimplementedGossipServiceHandler) Join(context.Context, *connect.Request[v1.JoinRequest]) (*connect.Response[v1.JoinResponse], error)
- func (UnimplementedGossipServiceHandler) Leave(context.Context, *connect.Request[v1.LeaveRequest]) (*connect.Response[v1.LeaveResponse], error)
- func (UnimplementedGossipServiceHandler) Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error)
- func (UnimplementedGossipServiceHandler) SyncMembers(context.Context, *connect.Request[v1.SyncMembersRequest]) (*connect.Response[v1.SyncMembersResponse], error)
Constants ¶
const ( // GossipServicePingProcedure is the fully-qualified name of the GossipService's Ping RPC. GossipServicePingProcedure = "/gossip.v1.GossipService/Ping" // GossipServiceIndirectPingProcedure is the fully-qualified name of the GossipService's // IndirectPing RPC. GossipServiceIndirectPingProcedure = "/gossip.v1.GossipService/IndirectPing" // GossipServiceSyncMembersProcedure is the fully-qualified name of the GossipService's SyncMembers // RPC. GossipServiceSyncMembersProcedure = "/gossip.v1.GossipService/SyncMembers" // GossipServiceJoinProcedure is the fully-qualified name of the GossipService's Join RPC. GossipServiceJoinProcedure = "/gossip.v1.GossipService/Join" // GossipServiceLeaveProcedure is the fully-qualified name of the GossipService's Leave RPC. GossipServiceLeaveProcedure = "/gossip.v1.GossipService/Leave" )
These constants are the fully-qualified names of the RPCs defined in this package. They're exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
Note that these are different from the fully-qualified method names used by google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to reflection-formatted method names, remove the leading slash and convert the remaining slash to a period.
const (
// GossipServiceName is the fully-qualified name of the GossipService service.
GossipServiceName = "gossip.v1.GossipService"
)
Variables ¶
This section is empty.
Functions ¶
func NewGossipServiceHandler ¶
func NewGossipServiceHandler(svc GossipServiceHandler, opts ...connect.HandlerOption) (string, http.Handler)
NewGossipServiceHandler builds an HTTP handler from the service implementation. It returns the path on which to mount the handler and the handler itself.
By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf and JSON codecs. They also support gzip compression.
Types ¶
type GossipServiceClient ¶
type GossipServiceClient interface { // Ping asks for the state of a peer // If the peer is healthy, it should respond with its state Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) // IndirectPing asks a peer to ping another node because we can not reach it outselves // the peer should respond with the state of the node IndirectPing(context.Context, *connect.Request[v1.IndirectPingRequest]) (*connect.Response[v1.IndirectPingResponse], error) // Periodially we do a full sync of the members // Both nodes tell each other about every member they know and then reconcile by taking the union // of the two sets. // Afterwards, both nodes should have the same view of the cluster and regular gossip will get rid // of any dead nodes // // If they disagree on the state of a node, the most favourable state should be chosen // ie: if one node thinks a peer is dead and the other thinks it is alive, the node should be // marked as alive to prevent a split brain or unnecessary false positives SyncMembers(context.Context, *connect.Request[v1.SyncMembersRequest]) (*connect.Response[v1.SyncMembersResponse], error) // Join allows a node to advertise itself to the cluster // The node sends their own information, so the cluster may add them to the list of known members // The cluster responds with the list of known members to bootstrap the new node // // It's sufficient to call join on one node, the rest of the cluster will be updated through // gossip, however it is recommended to call join on multiple nodes to ensure the information is // propagated quickly and to minimize the chance of a single node failing before propagating the // information. Join(context.Context, *connect.Request[v1.JoinRequest]) (*connect.Response[v1.JoinResponse], error) // Leave should be broadcasted to all nodes in the cluster when a node is leaving for any reason. Leave(context.Context, *connect.Request[v1.LeaveRequest]) (*connect.Response[v1.LeaveResponse], error) }
GossipServiceClient is a client for the gossip.v1.GossipService service.
func NewGossipServiceClient ¶
func NewGossipServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) GossipServiceClient
NewGossipServiceClient constructs a client for the gossip.v1.GossipService service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options.
The URL supplied here should be the base URL for the Connect or gRPC server (for example, http://api.acme.com or https://acme.com/grpc).
type GossipServiceHandler ¶
type GossipServiceHandler interface { // Ping asks for the state of a peer // If the peer is healthy, it should respond with its state Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) // IndirectPing asks a peer to ping another node because we can not reach it outselves // the peer should respond with the state of the node IndirectPing(context.Context, *connect.Request[v1.IndirectPingRequest]) (*connect.Response[v1.IndirectPingResponse], error) // Periodially we do a full sync of the members // Both nodes tell each other about every member they know and then reconcile by taking the union // of the two sets. // Afterwards, both nodes should have the same view of the cluster and regular gossip will get rid // of any dead nodes // // If they disagree on the state of a node, the most favourable state should be chosen // ie: if one node thinks a peer is dead and the other thinks it is alive, the node should be // marked as alive to prevent a split brain or unnecessary false positives SyncMembers(context.Context, *connect.Request[v1.SyncMembersRequest]) (*connect.Response[v1.SyncMembersResponse], error) // Join allows a node to advertise itself to the cluster // The node sends their own information, so the cluster may add them to the list of known members // The cluster responds with the list of known members to bootstrap the new node // // It's sufficient to call join on one node, the rest of the cluster will be updated through // gossip, however it is recommended to call join on multiple nodes to ensure the information is // propagated quickly and to minimize the chance of a single node failing before propagating the // information. Join(context.Context, *connect.Request[v1.JoinRequest]) (*connect.Response[v1.JoinResponse], error) // Leave should be broadcasted to all nodes in the cluster when a node is leaving for any reason. Leave(context.Context, *connect.Request[v1.LeaveRequest]) (*connect.Response[v1.LeaveResponse], error) }
GossipServiceHandler is an implementation of the gossip.v1.GossipService service.
type UnimplementedGossipServiceHandler ¶
type UnimplementedGossipServiceHandler struct{}
UnimplementedGossipServiceHandler returns CodeUnimplemented from all methods.
func (UnimplementedGossipServiceHandler) IndirectPing ¶
func (UnimplementedGossipServiceHandler) IndirectPing(context.Context, *connect.Request[v1.IndirectPingRequest]) (*connect.Response[v1.IndirectPingResponse], error)
func (UnimplementedGossipServiceHandler) Join ¶
func (UnimplementedGossipServiceHandler) Join(context.Context, *connect.Request[v1.JoinRequest]) (*connect.Response[v1.JoinResponse], error)
func (UnimplementedGossipServiceHandler) Leave ¶
func (UnimplementedGossipServiceHandler) Leave(context.Context, *connect.Request[v1.LeaveRequest]) (*connect.Response[v1.LeaveResponse], error)
func (UnimplementedGossipServiceHandler) Ping ¶
func (UnimplementedGossipServiceHandler) Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error)
func (UnimplementedGossipServiceHandler) SyncMembers ¶
func (UnimplementedGossipServiceHandler) SyncMembers(context.Context, *connect.Request[v1.SyncMembersRequest]) (*connect.Response[v1.SyncMembersResponse], error)