Documentation ¶
Index ¶
- Constants
- Variables
- type K8sLeaderEngine
- type K8sLeaderEngineOption
- func WithContext(ctx context.Context) K8sLeaderEngineOption
- func WithErrorLogger(logger Logger) K8sLeaderEngineOption
- func WithHolderIdentity(identity string) K8sLeaderEngineOption
- func WithLeaseDuration(dur time.Duration) K8sLeaderEngineOption
- func WithLeaseName(name string) K8sLeaderEngineOption
- func WithLeaseNamespace(namespace string) K8sLeaderEngineOption
- func WithLogger(logger Logger) K8sLeaderEngineOption
- func WithRenewTime(dur time.Duration) K8sLeaderEngineOption
- func WithRetryPeriod(dur time.Duration) K8sLeaderEngineOption
- type Logger
Constants ¶
View Source
const ( ServiceAccountMountPath = "/var/run/secrets/kubernetes.io/serviceaccount" DefaultKubernetesAPIServer = "https://kubernetes.default.svc" )
Variables ¶
View Source
var ( GetAPIClient = func() (k8s.Interface, error) { config, err := rest.InClusterConfig() if err != nil { return nil, fmt.Errorf("failed to get in-cluster config, err: %v", err) } apiClient, err := k8s.NewForConfig(config) if err != nil { return nil, fmt.Errorf("failed to obtain K8s API client, err: %v", err) } return apiClient, nil } ErrNotRunning = fmt.Errorf("leader engine is not running") )
Functions ¶
This section is empty.
Types ¶
type K8sLeaderEngine ¶
type K8sLeaderEngine struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...K8sLeaderEngineOption) (*K8sLeaderEngine, error)
func (*K8sLeaderEngine) GetLeader ¶
func (le *K8sLeaderEngine) GetLeader() string
func (*K8sLeaderEngine) IsLeader ¶
func (le *K8sLeaderEngine) IsLeader() bool
func (*K8sLeaderEngine) Start ¶
func (le *K8sLeaderEngine) Start() error
Start the leader engine and block until a leader is elected.
func (*K8sLeaderEngine) Stop ¶
func (le *K8sLeaderEngine) Stop() error
Stop the engine and wait until the goroutines have stopped
type K8sLeaderEngineOption ¶
type K8sLeaderEngineOption func(*K8sLeaderEngine)
func WithContext ¶
func WithContext(ctx context.Context) K8sLeaderEngineOption
func WithErrorLogger ¶
func WithErrorLogger(logger Logger) K8sLeaderEngineOption
func WithHolderIdentity ¶
func WithHolderIdentity(identity string) K8sLeaderEngineOption
func WithLeaseDuration ¶
func WithLeaseDuration(dur time.Duration) K8sLeaderEngineOption
func WithLeaseName ¶
func WithLeaseName(name string) K8sLeaderEngineOption
func WithLeaseNamespace ¶
func WithLeaseNamespace(namespace string) K8sLeaderEngineOption
func WithLogger ¶
func WithLogger(logger Logger) K8sLeaderEngineOption
func WithRenewTime ¶
func WithRenewTime(dur time.Duration) K8sLeaderEngineOption
func WithRetryPeriod ¶
func WithRetryPeriod(dur time.Duration) K8sLeaderEngineOption
Click to show internal directories.
Click to hide internal directories.