leaderelection

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2020 Mirantis, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LeaseConfiguration

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

The LeaseConfiguration allows passing through various options to customise the lease.

type LeaseEvents

type LeaseEvents struct {
	AcquiredLease chan struct{}
	LostLease     chan struct{}
}

LeaseEvents contains channels to inform the consumer when a lease is acquired and lost

type LeaseOpt

type LeaseOpt func(config LeaseConfiguration) LeaseConfiguration

A LeaseOpt is a function that modifies a LeaseConfiguration

func WithContext

func WithContext(ctx context.Context) LeaseOpt

WithContext allows the consumer to pass its own context, for example a cancelable context

func WithDuration

func WithDuration(duration time.Duration) LeaseOpt

WithDuration sets the duration of the lease (for new leases)

func WithIdentity

func WithIdentity(identity string) LeaseOpt

WithIdentity sets the identity of the lease holder

func WithLogger

func WithLogger(logger *logrus.Entry) LeaseOpt

WithLogger allows the consumer to pass a different logrus entry with additional context

func WithNamespace

func WithNamespace(namespace string) LeaseOpt

WithNamespace specifies which namespace the lease should be created in, defaults to kube-node-lease

func WithRenewDeadline

func WithRenewDeadline(deadline time.Duration) LeaseOpt

WithRenewDeadline sets the renew deadline of the lease

func WithRetryPeriod

func WithRetryPeriod(retryPeriod time.Duration) LeaseOpt

WithRetryPeriod specifies the retry period of the lease

type LeasePool

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

The LeasePool represents a single lease accessed by multiple clients (considered part of the "pool")

func NewLeasePool

func NewLeasePool(client kubernetes.Interface, name string, opts ...LeaseOpt) (*LeasePool, error)

NewLeasePool creates a new LeasePool struct to interact with a lease

func (*LeasePool) Watch

func (p *LeasePool) Watch(opts ...WatchOpt) (*LeaseEvents, context.CancelFunc, error)

Watch is the primary function of LeasePool, and starts the leader election process

type WatchOpt

type WatchOpt func(options watchOptions) watchOptions

WatchOpt is a callback that alters the watchOptions configuration

func WithOutputChannels

func WithOutputChannels(channels *LeaseEvents) WatchOpt

WithOutputChannels allows us to pass through channels with a size greater than 0, which makes testing a lot easier.

Jump to

Keyboard shortcuts

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