sender

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unary added in v0.8.0

Unary is a interceptor that records API usage for gRPC calls with the user info.

Types

type Config

type Config struct {
	// Enable is the flag to enable the sender.
	Enable bool `yaml:"enable"`
	// APIUsageInternalServerAddr is the address of the server to send usage data to.
	APIUsageInternalServerAddr string `yaml:"apiUsageInternalServerAddr"`
	// InitialDelay is the time to wait before starting the sender.
	InitialDelay time.Duration `yaml:"initialDelay"`
	// Interval is the interval at which the sender sends usage data to the server.
	Interval time.Duration `yaml:"interval"`
	// UsageChannelSize is the size of the channel that stores usage data.
	UsageChannelSize int `yaml:"usageChannelSize"`
	// MaxMessageSize is the maximum size of a message that the sender can send one gRPC call.
	MaxMessageSize int `yaml:"maxMessageSize"`
}

Config is the configuration for the sender.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type NoopUsageSetter added in v0.7.0

type NoopUsageSetter struct{}

NoopUsageSetter does nothing.

func (NoopUsageSetter) AddUsage added in v0.7.0

func (s NoopUsageSetter) AddUsage(usage *v1.UsageRecord)

AddUsage does nothing

type UsageSender

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

UsageSender is a component that sends usage data to the API server.

func New

func New(ctx context.Context, c Config, opt grpc.DialOption, log logr.Logger) (*UsageSender, error)

New creates a new UsageSender.

func (*UsageSender) AddUsage

func (s *UsageSender) AddUsage(usage *v1.UsageRecord)

AddUsage adds a usage record to the sender.

func (*UsageSender) Run

func (s *UsageSender) Run(ctx context.Context)

Run starts the usage sender. It sends usage data to the usage collector. If the maximum message size is exceeded, the sender will send the data immediately.

type UsageSetter

type UsageSetter interface {
	AddUsage(usage *v1.UsageRecord)
}

UsageSetter is an interface that allows components to add usage data to the sender.

Jump to

Keyboard shortcuts

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