Documentation ¶
Index ¶
Constants ¶
View Source
const ( // NumNodes is the number of nodes we offer (max 1024) NumNodes = 10 // GrpcPort is the port our gRPC server runs on GrpcPort = 50051 )
Variables ¶
View Source
var ( // HeartbeatPeriodicity is how often apps should heartbeat before we requisition their node IDs. HeartbeatPeriodicity = getHeartbeatPeriodicity() // StaleCheckPeriodicity is how often we check for stale node IDs StaleCheckPeriodicity = time.Second * 5 )
View Source
var AvailableNodeIds = make(chan int, NumNodes)
AvailableNodeIds is a channel of available node IDs. As nodes die, their node IDs will be requisitioned and sent into the channel.
View Source
var Heartbeats map[int]time.Time
Heartbeats stores the last time nodes sent a heartbeat.
Functions ¶
func PruneStaleEntries ¶
PruneStaleEntries checks for stale node IDs.
Types ¶
type GrpcServer ¶
type GrpcServer struct {
// contains filtered or unexported fields
}
GrpcServer is a gRPC server that provides an endpoint which allows apps to send "heartbeats" to request node IDs.
func (*GrpcServer) Heartbeat ¶
func (service *GrpcServer) Heartbeat(ctx context.Context, in *pb.HeartbeatRequest) (*pb.HeartbeatResponse, error)
Heartbeat is a gRPC endpoint to allow apps to request a node ID.
Click to show internal directories.
Click to hide internal directories.