ring

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHandleGone = errors.New("ring handle no longer exists")

ErrHandleGone is wrapped by Acquire's error when the name no longer maps to the given handle: the ring was deleted, possibly recreated under the same name with a new handle, between a caller's lookup and its acquire.

A caller distinguishes this race, which it may treat as "the ring is gone", from any other reason Acquire could fail.

View Source
var ServiceName = ringpb.RingService_ServiceDesc.ServiceName

ServiceName is the full gRPC name of the ring management service.

It comes from the generated service descriptor.

Functions

This section is empty.

Types

type Handle

type Handle uint64

Handle identifies one ring from its create to its delete.

If a ring is deleted and then created again under the same name, the new ring gets a new handle. A lease taken for the old handle never matches the new ring.

type Lease

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

Lease blocks the delete of one ring handle until Release.

A lease comes from RingService.Acquire. Release is the only way to remove the block. It is safe to call more than once. It only affects the handle the lease was taken for.

func (*Lease) Handle

func (m *Lease) Handle() Handle

Handle returns the handle this lease pins.

func (*Lease) Object

func (m *Lease) Object() *cring.Object

Object returns the ring object this lease pins.

It is valid while the lease is held. A consumer that holds the lease past Release must not keep using the value Object returned: the ring may be freed as soon as no lease pins it any more.

func (*Lease) Release

func (m *Lease) Release()

Release removes this lease's block on delete.

It is safe to call more than once.

type Option

type Option func(*options)

Option configures a RingService.

func WithLog

func WithLog(log *zap.Logger) Option

WithLog sets the ring service logger.

type RingService

type RingService struct {
	ringpb.UnimplementedRingServiceServer
	// contains filtered or unexported fields
}

RingService implements the gRPC service for standalone named rings.

It owns every ring it creates. It is the only code that frees a ring. It also gives out the leases that a consumer uses to bind to a ring by handle.

func NewRingService

func NewRingService(agent *ffi.Agent, opts ...Option) *RingService

NewRingService creates a new RingService.

func (*RingService) Acquire

func (m *RingService) Acquire(name string, handle Handle) (*Lease, error)

Acquire blocks the delete of the named ring and returns a lease.

It succeeds only if the name still maps to the given handle. Acquire fails once that ring is deleted, even if a new ring exists under the same name. The new ring got its own handle when it was created. Releasing the lease removes the block.

func (*RingService) CreateRing

CreateRing creates a named ring or, when allowed, preserves a matching one.

A matching managed ring keeps its records, readers, handle and leases without publication. Conflicts return AlreadyExists; an unmanaged publication returns FailedPrecondition only when existing rings are allowed.

func (*RingService) DeleteRing

DeleteRing removes a named ring.

The delete is refused in two cases: a lease from Acquire holds the ring, or a published module config links the ring by name. In both cases the ring stays registered and usable. The caller must release the lease or update the linking module, then retry.

func (*RingService) ListRings

ListRings returns every registered ring, sorted by name.

Each ring has the same fields that ShowRing returns.

func (*RingService) LookupHandle

func (m *RingService) LookupHandle(name string) (Handle, bool)

LookupHandle returns the handle registered under a name.

A consumer uses it to turn a configured ring name into the handle it binds through.

func (*RingService) ReclaimDeferred

func (m *RingService) ReclaimDeferred()

ReclaimDeferred tries again to free every deferred ring.

It keeps only the rings that a live generation still references. A ring whose free fails for another reason is logged and dropped. The service runs it before every create and delete and after a successful delete. Other code may call it at any time.

func (*RingService) Register

func (m *RingService) Register(server *grpc.Server)

Register registers the ring service on the given gRPC server.

func (*RingService) ServicesNames

func (m *RingService) ServicesNames() []string

ServicesNames returns the gRPC service names that this service serves.

func (*RingService) ShowRing

ShowRing returns one named ring: its name, per-worker capacity and publish batch.

Directories

Path Synopsis
ringpb
v1

Jump to

Keyboard shortcuts

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