Documentation ¶
Overview ¶
Package leaderproxy provides a gRPC interceptor that proxies requests to the leader node.
Index ¶
Constants ¶
const ( // PreferLeaderMeta is the metadata key for the Prefer-Leader header. PreferLeaderMeta = "x-webmesh-prefer-leader" // ProxiedFromMeta is the metadata key for the Proxied-From header. ProxiedFromMeta = "x-webmesh-proxied-from" // ProxiedForMeta is the metadata key for the Proxied-For header. ProxiedForMeta = "x-webmesh-proxied-for" )
Variables ¶
var MethodPolicyMap = map[string]MethodPolicy{ v1.Membership_Join_FullMethodName: RequireLeader, v1.Membership_Update_FullMethodName: RequireLeader, v1.Membership_Leave_FullMethodName: RequireLeader, v1.Membership_Apply_FullMethodName: RequireLeader, v1.Membership_SubscribePeers_FullMethodName: AllowNonLeader, v1.Membership_GetRaftConfiguration_FullMethodName: AllowNonLeader, v1.Node_GetStatus_FullMethodName: RequireLocal, v1.Node_NegotiateDataChannel_FullMethodName: RequireLocal, v1.Storage_Query_FullMethodName: AllowNonLeader, v1.Storage_Publish_FullMethodName: AllowNonLeader, v1.Storage_Subscribe_FullMethodName: RequireLocal, v1.Mesh_GetNode_FullMethodName: AllowNonLeader, v1.Mesh_ListNodes_FullMethodName: AllowNonLeader, v1.Mesh_GetMeshGraph_FullMethodName: AllowNonLeader, v1.WebRTC_StartDataChannel_FullMethodName: AllowNonLeader, v1.Admin_PutRole_FullMethodName: RequireLeader, v1.Admin_DeleteRole_FullMethodName: RequireLeader, v1.Admin_GetRole_FullMethodName: AllowNonLeader, v1.Admin_ListRoles_FullMethodName: AllowNonLeader, v1.Admin_PutRoleBinding_FullMethodName: RequireLeader, v1.Admin_DeleteRoleBinding_FullMethodName: RequireLeader, v1.Admin_GetRoleBinding_FullMethodName: AllowNonLeader, v1.Admin_ListRoleBindings_FullMethodName: AllowNonLeader, v1.Admin_PutGroup_FullMethodName: RequireLeader, v1.Admin_DeleteGroup_FullMethodName: RequireLeader, v1.Admin_GetGroup_FullMethodName: AllowNonLeader, v1.Admin_ListGroups_FullMethodName: AllowNonLeader, v1.Admin_PutNetworkACL_FullMethodName: RequireLeader, v1.Admin_DeleteNetworkACL_FullMethodName: RequireLeader, v1.Admin_GetNetworkACL_FullMethodName: AllowNonLeader, v1.Admin_ListNetworkACLs_FullMethodName: AllowNonLeader, v1.Admin_PutRoute_FullMethodName: RequireLeader, v1.Admin_DeleteRoute_FullMethodName: RequireLeader, v1.Admin_GetRoute_FullMethodName: AllowNonLeader, v1.Admin_ListRoutes_FullMethodName: AllowNonLeader, v1.Admin_PutEdge_FullMethodName: RequireLeader, v1.Admin_DeleteEdge_FullMethodName: RequireLeader, v1.Admin_GetEdge_FullMethodName: AllowNonLeader, v1.Admin_ListEdges_FullMethodName: AllowNonLeader, }
MethodPolicyMap is a map of method names to their MethodPolicy.
Functions ¶
func HasPreferLeaderMeta ¶
HasPreferLeaderMeta returns true if the context has the Prefer-Leader header set to true.
func ProxiedFor ¶
ProxiedFor returns the node ID of the node that the request was proxied for. If the request was not proxied then false is returned.
func ProxiedFrom ¶
ProxiedFrom returns the node ID of the node that proxied the request. If the request was not proxied then false is returned.
func RouteRequiresInNetworkSource ¶ added in v0.3.0
RouteRequiresInNetworkSource returns true if the given route requires that the request is routed from a peer in the network.
Types ¶
type Dialer ¶ added in v0.3.0
type Dialer interface { transport.LeaderDialer transport.NodeDialer }
Dialer is the interface required for the leader proxy interceptor.
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor is the leaderproxy interceptor.
func (*Interceptor) StreamInterceptor ¶
func (i *Interceptor) StreamInterceptor() grpc.StreamServerInterceptor
StreamInterceptor returns a gRPC stream interceptor that proxies requests to the leader node.
func (*Interceptor) UnaryInterceptor ¶
func (i *Interceptor) UnaryInterceptor() grpc.UnaryServerInterceptor
UnaryInterceptor returns a gRPC unary interceptor that proxies requests to the leader node.
type MethodPolicy ¶
type MethodPolicy int
MethodPolicy defines the policy for routing requests to the leader.
const ( // RequireLeader requires that the request is routed to the leader. RequireLeader MethodPolicy = iota // AllowNonLeader allows the request to be routed to a non-leader. AllowNonLeader // RequireLocal requires that the request is routed to the local node. RequireLocal )