zero

package
v25.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Zero is the sub-command used to start Zero servers.

Functions

This section is empty.

Types

type Oracle

type Oracle struct {
	x.SafeMutex
	// contains filtered or unexported fields
}

Oracle stores and manages the transaction state and conflict detection.

func (*Oracle) Init

func (o *Oracle) Init()

Init initializes the oracle.

func (*Oracle) MaxPending

func (o *Oracle) MaxPending() uint64

MaxPending returns the maximum assigned timestamp.

type Server

type Server struct {
	x.SafeMutex
	Node *node

	NumReplicas int

	// embedding the pb.UnimplementedZeroServer struct to ensure forward compatibility of the server.
	pb.UnimplementedZeroServer
	// contains filtered or unexported fields
}

Server implements the zero server.

func (*Server) AssignIds

func (s *Server) AssignIds(ctx context.Context, num *pb.Num) (*pb.AssignedIds, error)

AssignIds is used to assign new ids (UIDs, NsIDs) by communicating with the leader of the RAFT group responsible for handing out ids. If bump is set to true in the request then the lease for the given id type is bumped to num.Val and {startId, endId} of the newly leased ids in the process of bump is returned.

func (*Server) CommitOrAbort

func (s *Server) CommitOrAbort(ctx context.Context, src *api.TxnContext) (*api.TxnContext, error)

CommitOrAbort either commits a transaction or aborts it. The abortion can happen under the following conditions 1) the api.TxnContext.Aborted flag is set in the src argument 2) if there's an error (e.g server is not the leader or there's a conflicting transaction)

func (*Server) Connect

func (s *Server) Connect(ctx context.Context,
	m *pb.Member) (resp *pb.ConnectionState, err error)

Connect is used by Alpha nodes to connect the very first time with group zero.

func (*Server) DeleteNamespace

func (s *Server) DeleteNamespace(ctx context.Context, in *pb.DeleteNsRequest) (*pb.Status, error)

DeleteNamespace removes the tablets for deleted namespace from the membership state.

func (*Server) Inform

func (s *Server) Inform(ctx context.Context, req *pb.TabletRequest) (*pb.TabletResponse, error)

func (*Server) Init

func (s *Server) Init()

Init initializes the zero server.

func (*Server) KnownGroups

func (s *Server) KnownGroups() []uint32

KnownGroups returns a list of the known groups.

func (*Server) Leader

func (s *Server) Leader(gid uint32) *conn.Pool

Leader returns a connection pool to the zero leader.

func (*Server) MarshalMembershipState

func (s *Server) MarshalMembershipState() ([]byte, error)

MarshalMembershipState returns the marshaled membership state.

func (*Server) MoveTablet

func (s *Server) MoveTablet(ctx context.Context, req *pb.MoveTabletRequest) (*pb.Status, error)

MoveTablet can be used to move a tablet to a specific group. It takes in tablet and destination group as argument. It returns a *pb.Status to be used by the `/moveTablet` HTTP handler in Zero.

func (*Server) Oracle

func (s *Server) Oracle(_ *api.Payload, server pb.Zero_OracleServer) error

Oracle streams the oracle state to the alphas. The first entry sent by Zero contains the entire state of transactions. Zero periodically confirms receipt from the group, and truncates its state. This 2-way acknowledgement is a safe way to get the status of all the transactions.

func (*Server) RemoveNode

func (s *Server) RemoveNode(ctx context.Context, req *pb.RemoveNodeRequest) (*pb.Status, error)

RemoveNode removes the given node from the given group. It's the user's responsibility to ensure that node doesn't come back again before calling the api.

func (*Server) ServingTablet

func (s *Server) ServingTablet(tablet string) *pb.Tablet

ServingTablet returns the Tablet called tablet.

func (*Server) SetMembershipState

func (s *Server) SetMembershipState(state *pb.MembershipState)

SetMembershipState updates the membership state to the given one.

func (*Server) ShouldServe

func (s *Server) ShouldServe(
	ctx context.Context, tablet *pb.Tablet) (resp *pb.Tablet, err error)

ShouldServe returns the tablet serving the predicate passed in the request.

func (*Server) StreamMembership

func (s *Server) StreamMembership(_ *api.Payload, stream pb.Zero_StreamMembershipServer) error

StreamMembership periodically streams the membership state to the given stream.

func (*Server) Timestamps

func (s *Server) Timestamps(ctx context.Context, num *pb.Num) (*pb.AssignedIds, error)

Timestamps is used to assign startTs for a new transaction

func (*Server) TryAbort

func (s *Server) TryAbort(ctx context.Context,
	txns *pb.TxnTimestamps) (*pb.OracleDelta, error)

TryAbort attempts to abort the given transactions which are not already committed..

func (*Server) UpdateMembership

func (s *Server) UpdateMembership(ctx context.Context, group *pb.Group) (*api.Payload, error)

UpdateMembership updates the membership of the given group.

Jump to

Keyboard shortcuts

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