nodepb

package
v0.0.0-...-364fed7 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package nodepb holds protobuf descriptions for a node within a Croissant cluster.

Index

Constants

This section is empty.

Variables

View Source
var (
	Health_name = map[int32]string{
		0: "HEALTHY",
		1: "UNHEALTHY",
		2: "DEAD",
	}
	Health_value = map[string]int32{
		"HEALTHY":   0,
		"UNHEALTHY": 1,
		"DEAD":      2,
	}
)

Enum value maps for Health.

View Source
var Node_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "croissant.v1.Node",
	HandlerType: (*NodeServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Join",
			Handler:    _Node_Join_Handler,
		},
		{
			MethodName: "Hello",
			Handler:    _Node_Hello_Handler,
		},
		{
			MethodName: "Goodbye",
			Handler:    _Node_Goodbye_Handler,
		},
		{
			MethodName: "GetState",
			Handler:    _Node_GetState_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "node.proto",
}

Node_ServiceDesc is the grpc.ServiceDesc for Node service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterNodeServer

func RegisterNodeServer(s grpc.ServiceRegistrar, srv NodeServer)

func ToAPI

func ToAPI(c NodeClient) api.Node

ToAPI converts NodeClient into an api.Node.

func WithCallOptions

func WithCallOptions(ctx context.Context, opts ...grpc.CallOption) context.Context

Types

type Descriptor

type Descriptor struct {

	// id within the ring. Any token whose value is equal or closer to this id
	// than any other id from other nodes will be assigned ownership to this
	// node.
	Id *ID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// Address of the node, used for both inter-node communication and for
	// clients to send requests.
	Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
	// contains filtered or unexported fields
}

Descriptor describes a node within a cluster.

func (*Descriptor) Descriptor deprecated

func (*Descriptor) Descriptor() ([]byte, []int)

Deprecated: Use Descriptor.ProtoReflect.Descriptor instead.

func (*Descriptor) GetAddr

func (x *Descriptor) GetAddr() string

func (*Descriptor) GetId

func (x *Descriptor) GetId() *ID

func (*Descriptor) ProtoMessage

func (*Descriptor) ProtoMessage()

func (*Descriptor) ProtoReflect

func (x *Descriptor) ProtoReflect() protoreflect.Message

func (*Descriptor) Reset

func (x *Descriptor) Reset()

func (*Descriptor) String

func (x *Descriptor) String() string

type DescriptorHealth

type DescriptorHealth struct {

	// The peer this DescriptorHealth is for.
	Peer *Descriptor `protobuf:"bytes,1,opt,name=peer,proto3" json:"peer,omitempty"`
	// The health of the peer.
	Health Health `protobuf:"varint,2,opt,name=health,proto3,enum=croissant.v1.Health" json:"health,omitempty"`
	// contains filtered or unexported fields
}

func (*DescriptorHealth) Descriptor deprecated

func (*DescriptorHealth) Descriptor() ([]byte, []int)

Deprecated: Use DescriptorHealth.ProtoReflect.Descriptor instead.

func (*DescriptorHealth) GetHealth

func (x *DescriptorHealth) GetHealth() Health

func (*DescriptorHealth) GetPeer

func (x *DescriptorHealth) GetPeer() *Descriptor

func (*DescriptorHealth) ProtoMessage

func (*DescriptorHealth) ProtoMessage()

func (*DescriptorHealth) ProtoReflect

func (x *DescriptorHealth) ProtoReflect() protoreflect.Message

func (*DescriptorHealth) Reset

func (x *DescriptorHealth) Reset()

func (*DescriptorHealth) String

func (x *DescriptorHealth) String() string

type GetStateRequest

type GetStateRequest struct {
	// contains filtered or unexported fields
}

GetStateRequest requests the state from a node.

func (*GetStateRequest) Descriptor deprecated

func (*GetStateRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetStateRequest.ProtoReflect.Descriptor instead.

func (*GetStateRequest) ProtoMessage

func (*GetStateRequest) ProtoMessage()

func (*GetStateRequest) ProtoReflect

func (x *GetStateRequest) ProtoReflect() protoreflect.Message

func (*GetStateRequest) Reset

func (x *GetStateRequest) Reset()

func (*GetStateRequest) String

func (x *GetStateRequest) String() string

type GetStateResponse

type GetStateResponse struct {

	// State holds the state of the node.
	State *State `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"`
	// contains filtered or unexported fields
}

func (*GetStateResponse) Descriptor deprecated

func (*GetStateResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetStateResponse.ProtoReflect.Descriptor instead.

func (*GetStateResponse) GetState

func (x *GetStateResponse) GetState() *State

func (*GetStateResponse) ProtoMessage

func (*GetStateResponse) ProtoMessage()

func (*GetStateResponse) ProtoReflect

func (x *GetStateResponse) ProtoReflect() protoreflect.Message

func (*GetStateResponse) Reset

func (x *GetStateResponse) Reset()

func (*GetStateResponse) String

func (x *GetStateResponse) String() string

type GoodbyeRequest

type GoodbyeRequest struct {

	// The node leaving the cluster.
	Node *Descriptor `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"`
	// contains filtered or unexported fields
}

func (*GoodbyeRequest) Descriptor deprecated

func (*GoodbyeRequest) Descriptor() ([]byte, []int)

Deprecated: Use GoodbyeRequest.ProtoReflect.Descriptor instead.

func (*GoodbyeRequest) GetNode

func (x *GoodbyeRequest) GetNode() *Descriptor

func (*GoodbyeRequest) ProtoMessage

func (*GoodbyeRequest) ProtoMessage()

func (*GoodbyeRequest) ProtoReflect

func (x *GoodbyeRequest) ProtoReflect() protoreflect.Message

func (*GoodbyeRequest) Reset

func (x *GoodbyeRequest) Reset()

func (*GoodbyeRequest) String

func (x *GoodbyeRequest) String() string

type Health

type Health int32

State that peers can be in.

const (
	// The default State. The peer is healthy and may be freely communicated
	// with.
	Health_HEALTHY Health = 0
	// The peer is suspected to be unhealthy. Communications should be avoided
	// with this peer.
	Health_UNHEALTHY Health = 1
	// The peer is dead and will be removed from the routing table as soon as
	// possible.
	Health_DEAD Health = 2
)

func (Health) Descriptor

func (Health) Descriptor() protoreflect.EnumDescriptor

func (Health) Enum

func (x Health) Enum() *Health

func (Health) EnumDescriptor deprecated

func (Health) EnumDescriptor() ([]byte, []int)

Deprecated: Use Health.Descriptor instead.

func (Health) Number

func (x Health) Number() protoreflect.EnumNumber

func (Health) String

func (x Health) String() string

func (Health) Type

func (Health) Type() protoreflect.EnumType

type HelloRequest

type HelloRequest struct {

	// The node initiating the Hello.
	Initiator *Descriptor `protobuf:"bytes,1,opt,name=initiator,proto3" json:"initiator,omitempty"`
	// The next node, if any, that will also send a Hello.
	Next *Descriptor `protobuf:"bytes,2,opt,name=next,proto3" json:"next,omitempty"`
	// State of the initiator.
	State *State `protobuf:"bytes,3,opt,name=state,proto3" json:"state,omitempty"`
	// Ack ID identifies the Hello as the acknowledgement of a previous hello. The ID
	// is set to the state ID of the state of the receiver. If the receiver's
	// state ID has changed, it should reply with the new state.
	//
	// 0 indicates "not an acknowledgement".
	AckId uint64 `protobuf:"varint,4,opt,name=ack_id,json=ackId,proto3" json:"ack_id,omitempty"`
	// contains filtered or unexported fields
}

func (*HelloRequest) Descriptor deprecated

func (*HelloRequest) Descriptor() ([]byte, []int)

Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.

func (*HelloRequest) GetAckId

func (x *HelloRequest) GetAckId() uint64

func (*HelloRequest) GetInitiator

func (x *HelloRequest) GetInitiator() *Descriptor

func (*HelloRequest) GetNext

func (x *HelloRequest) GetNext() *Descriptor

func (*HelloRequest) GetState

func (x *HelloRequest) GetState() *State

func (*HelloRequest) ProtoMessage

func (*HelloRequest) ProtoMessage()

func (*HelloRequest) ProtoReflect

func (x *HelloRequest) ProtoReflect() protoreflect.Message

func (*HelloRequest) Reset

func (x *HelloRequest) Reset()

func (*HelloRequest) String

func (x *HelloRequest) String() string

type HelloResponse

type HelloResponse struct {

	// If ack_id was > 0 in in the Hello request and the state ID of the
	// receiver has changed, new_state should be set to the current state
	// of the receiver.
	NewState *State `protobuf:"bytes,1,opt,name=new_state,json=newState,proto3" json:"new_state,omitempty"`
	// contains filtered or unexported fields
}

func (*HelloResponse) Descriptor deprecated

func (*HelloResponse) Descriptor() ([]byte, []int)

Deprecated: Use HelloResponse.ProtoReflect.Descriptor instead.

func (*HelloResponse) GetNewState

func (x *HelloResponse) GetNewState() *State

func (*HelloResponse) ProtoMessage

func (*HelloResponse) ProtoMessage()

func (*HelloResponse) ProtoReflect

func (x *HelloResponse) ProtoReflect() protoreflect.Message

func (*HelloResponse) Reset

func (x *HelloResponse) Reset()

func (*HelloResponse) String

func (x *HelloResponse) String() string

type ID

type ID struct {
	High uint64 `protobuf:"varint,1,opt,name=high,proto3" json:"high,omitempty"`
	Low  uint64 `protobuf:"varint,2,opt,name=low,proto3" json:"low,omitempty"`
	// contains filtered or unexported fields
}

ID is a 128-bit number that identifies a node.

func (*ID) Descriptor deprecated

func (*ID) Descriptor() ([]byte, []int)

Deprecated: Use ID.ProtoReflect.Descriptor instead.

func (*ID) GetHigh

func (x *ID) GetHigh() uint64

func (*ID) GetLow

func (x *ID) GetLow() uint64

func (*ID) ProtoMessage

func (*ID) ProtoMessage()

func (*ID) ProtoReflect

func (x *ID) ProtoReflect() protoreflect.Message

func (*ID) Reset

func (x *ID) Reset()

func (*ID) String

func (x *ID) String() string

type JoinRequest

type JoinRequest struct {

	// The joiner is the node that is trying to join.
	Joiner *Descriptor `protobuf:"bytes,1,opt,name=joiner,proto3" json:"joiner,omitempty"`
	// contains filtered or unexported fields
}

func (*JoinRequest) Descriptor deprecated

func (*JoinRequest) Descriptor() ([]byte, []int)

Deprecated: Use JoinRequest.ProtoReflect.Descriptor instead.

func (*JoinRequest) GetJoiner

func (x *JoinRequest) GetJoiner() *Descriptor

func (*JoinRequest) ProtoMessage

func (*JoinRequest) ProtoMessage()

func (*JoinRequest) ProtoReflect

func (x *JoinRequest) ProtoReflect() protoreflect.Message

func (*JoinRequest) Reset

func (x *JoinRequest) Reset()

func (*JoinRequest) String

func (x *JoinRequest) String() string

type NodeClient

type NodeClient interface {
	// Join initiates a series of handshakes to join the ring as a new node.
	Join(ctx context.Context, in *JoinRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// Hello is used between two nodes to share their state. If the
	// HelloRequest is an Ack and state has been changed, should respond
	// with the new state.
	Hello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
	// Goodbye informs a node that a node is leaving the cluster.
	Goodbye(ctx context.Context, in *GoodbyeRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// GetState requests the state tables for this node.
	GetState(ctx context.Context, in *GetStateRequest, opts ...grpc.CallOption) (*GetStateResponse, error)
}

NodeClient is the client API for Node service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewNodeClient

func NewNodeClient(cc grpc.ClientConnInterface) NodeClient

type NodeServer

type NodeServer interface {
	// Join initiates a series of handshakes to join the ring as a new node.
	Join(context.Context, *JoinRequest) (*emptypb.Empty, error)
	// Hello is used between two nodes to share their state. If the
	// HelloRequest is an Ack and state has been changed, should respond
	// with the new state.
	Hello(context.Context, *HelloRequest) (*HelloResponse, error)
	// Goodbye informs a node that a node is leaving the cluster.
	Goodbye(context.Context, *GoodbyeRequest) (*emptypb.Empty, error)
	// GetState requests the state tables for this node.
	GetState(context.Context, *GetStateRequest) (*GetStateResponse, error)
	// contains filtered or unexported methods
}

NodeServer is the server API for Node service. All implementations must embed UnimplementedNodeServer for forward compatibility

func FromAPI

func FromAPI(n api.Node) NodeServer

FromAPI converts api.Node into a NodeServer.

type State

type State struct {

	// Descriptor of the node that this state belongs to.
	Node *Descriptor `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"`
	// Nodes that appear immediately before this node in the ring.
	Predecessors []*Descriptor `protobuf:"bytes,2,rep,name=predecessors,proto3" json:"predecessors,omitempty"`
	// Nodes that appear immediately after this node in the ring.
	Successors []*Descriptor `protobuf:"bytes,3,rep,name=successors,proto3" json:"successors,omitempty"`
	// The bit length used to represent IDs for routing. Must be one of
	// 8/16/32/64/128.
	IdBitLength uint32 `protobuf:"varint,4,opt,name=id_bit_length,json=idBitLength,proto3" json:"id_bit_length,omitempty"`
	// The base used to represent the ID for routing (i.e., hexadecimal,
	// base-16). Must be one of 2/4/8/16.
	IdBase uint32 `protobuf:"varint,5,opt,name=id_base,json=idBase,proto3" json:"id_base,omitempty"`
	// The 2D routing table used to route messages to far away nodes.
	// Key is the index in the routing table, where the position is
	// (width*y)+x.
	Routing map[uint32]*Descriptor `` /* 156-byte string literal not displayed */
	// List of nodes that are geographically located close to this node.
	Neighborhood []*Descriptor `protobuf:"bytes,7,rep,name=neighborhood,proto3" json:"neighborhood,omitempty"`
	// ID representing this table. A change to the table must change this ID.
	// It is common to use modified timestamp for this.
	StateId uint64 `protobuf:"varint,8,opt,name=state_id,json=stateId,proto3" json:"state_id,omitempty"`
	// A set of health of descriptors in the map. This MUST be sorted in order
	// of peer ID. Descriptors inside MUST be unique.
	HealthSet []*DescriptorHealth `protobuf:"bytes,9,rep,name=health_set,json=healthSet,proto3" json:"health_set,omitempty"`
	// contains filtered or unexported fields
}

State is the internal state of a node used for routing messages.

func (*State) Descriptor deprecated

func (*State) Descriptor() ([]byte, []int)

Deprecated: Use State.ProtoReflect.Descriptor instead.

func (*State) GetHealthSet

func (x *State) GetHealthSet() []*DescriptorHealth

func (*State) GetIdBase

func (x *State) GetIdBase() uint32

func (*State) GetIdBitLength

func (x *State) GetIdBitLength() uint32

func (*State) GetNeighborhood

func (x *State) GetNeighborhood() []*Descriptor

func (*State) GetNode

func (x *State) GetNode() *Descriptor

func (*State) GetPredecessors

func (x *State) GetPredecessors() []*Descriptor

func (*State) GetRouting

func (x *State) GetRouting() map[uint32]*Descriptor

func (*State) GetStateId

func (x *State) GetStateId() uint64

func (*State) GetSuccessors

func (x *State) GetSuccessors() []*Descriptor

func (*State) ProtoMessage

func (*State) ProtoMessage()

func (*State) ProtoReflect

func (x *State) ProtoReflect() protoreflect.Message

func (*State) Reset

func (x *State) Reset()

func (*State) String

func (x *State) String() string

type UnimplementedNodeServer

type UnimplementedNodeServer struct {
}

UnimplementedNodeServer must be embedded to have forward compatible implementations.

func (UnimplementedNodeServer) GetState

func (UnimplementedNodeServer) Goodbye

func (UnimplementedNodeServer) Hello

func (UnimplementedNodeServer) Join

type UnsafeNodeServer

type UnsafeNodeServer interface {
	// contains filtered or unexported methods
}

UnsafeNodeServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to NodeServer will result in compilation errors.

Jump to

Keyboard shortcuts

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