Documentation ¶
Overview ¶
Package rpc implements a rate-limited RPC service.
Index ¶
- func New() pb.DemoServer
- type Demo
- func (*Demo) GlobalQuotaReset(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)
- func (*Demo) GlobalRateLimit(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)
- func (*Demo) PerUserQuotaReset(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)
- func (*Demo) PerUserRateLimit(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Demo ¶
type Demo struct { }
Demo implements pb.DemoServer. Requires a quotaconfig.Interface in the context for all method calls.
func (*Demo) GlobalQuotaReset ¶
GlobalQuotaReset resets quota for calling GlobalRateLimit. Always succeeds, returning an *emptypb.Empty.
func (*Demo) GlobalRateLimit ¶
GlobalRateLimit is globally limited to one request every 60 seconds. This quota can be reset at any time by calling GlobalQuotaReset. On success, returns an *emptypb.Empty, and on failure returns a codes.ResourceExhausted gRPC error.
func (*Demo) PerUserQuotaReset ¶
PerUserQuotaReset resets the caller's own quota for calling PerUserRateLimit. Always succeeds, returning an *emptypb.Empty.
func (*Demo) PerUserRateLimit ¶
PerUserRateLimit is limited to two requests every 60 seconds for a given user. This quota can be reset at any time by calling PerUserQuotaReset. On success, returns an *emptypb.Empty, and on failure returns a codes.ResourceExhausted gRPC error.