rpc

package
v0.0.0-...-d3da680 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package rpc implements a rate-limited RPC service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() pb.DemoServer

New returns a new pb.DemoServer.

Types

type Demo

type Demo struct {
}

Demo implements pb.DemoServer. Requires a quotaconfig.Interface in the context for all method calls.

func (*Demo) GlobalQuotaReset

func (*Demo) GlobalQuotaReset(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

GlobalQuotaReset resets quota for calling GlobalRateLimit. Always succeeds, returning an *emptypb.Empty.

func (*Demo) GlobalRateLimit

func (*Demo) GlobalRateLimit(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

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

func (*Demo) PerUserQuotaReset(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

PerUserQuotaReset resets the caller's own quota for calling PerUserRateLimit. Always succeeds, returning an *emptypb.Empty.

func (*Demo) PerUserRateLimit

func (*Demo) PerUserRateLimit(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

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.

Jump to

Keyboard shortcuts

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