license

package
v2.12.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultPollingPeriod is the period at which the license agent will poll for license updates by default.
	DefaultPollingPeriod = time.Hour * 12

	// DefaultInitialPollingPeriod is the period at which the license agent will poll for a license until it retrieves
	// one.
	DefaultInitialPollingPeriod = time.Minute

	// PollingTimeout is the timeout for retrieving a license from upstream.
	PollingTimeout = time.Minute * 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent handles retrieving a Kong license and providing it to other KIC subsystems.

func NewAgent

func NewAgent(
	konnectLicenseClient KonnectLicenseClient,
	logger logr.Logger,
	opts ...AgentOpt,
) *Agent

NewAgent creates a new license agent that retrieves a license from the given url once every given period.

func (*Agent) GetLicense

func (a *Agent) GetLicense() mo.Option[kong.License]

GetLicense returns the agent's current license as a go-kong License struct. It omits the origin timestamps, as Kong will auto-populate these when adding the license to its config database. It's optional because we may not have retrieved a license yet.

func (*Agent) NeedLeaderElection

func (a *Agent) NeedLeaderElection() bool

NeedLeaderElection indicates if the Agent requires leadership to run. It always returns true.

func (*Agent) Start

func (a *Agent) Start(ctx context.Context) error

Start starts the Agent. It attempts to pull an initial license from upstream, and then polls for updates on a regular period, either the agent's initialPollingPeriod if it has not yet obtained a license or regularPollingPeriod if it has.

func (*Agent) Started added in v2.10.3

func (a *Agent) Started() <-chan struct{}

Started returns a channel which will be closed when the Agent has started.

type AgentOpt added in v2.10.1

type AgentOpt func(*Agent)

func WithInitialPollingPeriod added in v2.10.1

func WithInitialPollingPeriod(initialPollingPeriod time.Duration) AgentOpt

WithInitialPollingPeriod sets the initial polling period for the license agent.

func WithPollingPeriod added in v2.10.1

func WithPollingPeriod(regularPollingPeriod time.Duration) AgentOpt

WithPollingPeriod sets the regular polling period for the license agent.

func WithTicker added in v2.10.3

func WithTicker(t Ticker) AgentOpt

WithTicker sets the ticker in Agent. This is useful for testing. Ticker doesn't define the period, it defines the implementation of ticking.

type KonnectLicense added in v2.10.1

type KonnectLicense struct {
	ID        string
	Payload   string
	UpdatedAt time.Time
}

KonnectLicense is a license retrieved from Konnect.

type KonnectLicenseClient added in v2.10.1

type KonnectLicenseClient interface {
	Get(ctx context.Context) (mo.Option[KonnectLicense], error)
}

type Ticker added in v2.10.3

type Ticker interface {
	Stop()
	Channel() <-chan time.Time
	Reset(d time.Duration)
}

Jump to

Keyboard shortcuts

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