Documentation
¶
Index ¶
- Variables
- type Handle
- type Lease
- type Option
- type RingService
- func (m *RingService) Acquire(name string, handle Handle) (*Lease, error)
- func (m *RingService) CreateRing(ctx context.Context, req *ringpb.CreateRingRequest) (*ringpb.CreateRingResponse, error)
- func (m *RingService) DeleteRing(ctx context.Context, req *ringpb.DeleteRingRequest) (*ringpb.DeleteRingResponse, error)
- func (m *RingService) ListRings(ctx context.Context, req *ringpb.ListRingsRequest) (*ringpb.ListRingsResponse, error)
- func (m *RingService) LookupHandle(name string) (Handle, bool)
- func (m *RingService) ReclaimDeferred()
- func (m *RingService) Register(server *grpc.Server)
- func (m *RingService) ServicesNames() []string
- func (m *RingService) ShowRing(ctx context.Context, req *ringpb.ShowRingRequest) (*ringpb.ShowRingResponse, error)
Constants ¶
This section is empty.
Variables ¶
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.
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.
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 ¶
func (m *RingService) CreateRing( ctx context.Context, req *ringpb.CreateRingRequest, ) (*ringpb.CreateRingResponse, error)
CreateRing creates a new named ring and publishes it to the dataplane.
func (*RingService) DeleteRing ¶
func (m *RingService) DeleteRing( ctx context.Context, req *ringpb.DeleteRingRequest, ) (*ringpb.DeleteRingResponse, error)
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 ¶
func (m *RingService) ListRings( ctx context.Context, req *ringpb.ListRingsRequest, ) (*ringpb.ListRingsResponse, error)
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 on every 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 ¶
func (m *RingService) ShowRing( ctx context.Context, req *ringpb.ShowRingRequest, ) (*ringpb.ShowRingResponse, error)
ShowRing returns one named ring: its name, per-worker capacity and publish batch.