leadership

package
v0.0.0-...-298751d Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(registry facade.FacadeRegistry)

Register is called to expose a package of facades onto a given registry.

Types

type GetSettingsFn

type GetSettingsFn func(serviceId string) (map[string]string, error)

GetSettingsFn declares a function-type which will return leadership settings for the given service ID.

type LeaderCheckFn

type LeaderCheckFn func(serviceId, unitId string) leadership.Token

LeaderCheckFn returns a Token whose Check method will return an error if the unit is not leader of the service.

type LeadershipService

type LeadershipService interface {

	// ClaimLeadership makes a leadership claim with the given parameters.
	ClaimLeadership(params params.ClaimLeadershipBulkParams) (params.ClaimLeadershipBulkResults, error)

	// BlockUntilLeadershipReleased blocks the caller until leadership is
	// released for the given service.
	BlockUntilLeadershipReleased(ctx context.Context, ApplicationTag names.ApplicationTag) (params.ErrorResult, error)
}

LeadershipService implements a variant of leadership.Claimer for consumption over the API.

func NewLeadershipService

func NewLeadershipService(
	claimer leadership.Claimer, authorizer facade.Authorizer,
) (LeadershipService, error)

NewLeadershipService constructs a new LeadershipService.

type LeadershipSettingsAccessor

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

LeadershipSettingsAccessor provides a type which can read, write, and watch leadership settings.

func NewLeadershipSettingsAccessor

func NewLeadershipSettingsAccessor(
	authorizer facade.Authorizer,
	registerWatcherFn RegisterWatcherFn,
	getSettingsFn GetSettingsFn,
	leaderCheckFn LeaderCheckFn,
	mergeSettingsChunkFn MergeSettingsChunkFn,
) *LeadershipSettingsAccessor

NewLeadershipSettingsAccessor creates a new LeadershipSettingsAccessor.

func (*LeadershipSettingsAccessor) Merge

Merge merges in the provided leadership settings. Only leaders for the given service may perform this operation.

func (*LeadershipSettingsAccessor) Read

Read reads leadership settings for the provided service ID. Any unit of the service may perform this operation.

func (*LeadershipSettingsAccessor) WatchLeadershipSettings

func (lsa *LeadershipSettingsAccessor) WatchLeadershipSettings(bulkArgs params.Entities) (params.NotifyWatchResults, error)

WatchLeadershipSettings will block the caller until leadership settings for the given service ID change.

type MergeSettingsChunkFn

type MergeSettingsChunkFn func(token leadership.Token, serviceId string, settings map[string]string) error

MergeSettingsChunkFn declares a function-type which will write the provided settings chunk into the greater leadership settings for the provided service ID, so long as the supplied Token remains valid.

type RegisterWatcherFn

type RegisterWatcherFn func(serviceId string) (watcherId string, _ error)

RegisterWatcherFn declares a function-type which will return a channel that can be blocked on to be notified of setting changes for the provided document key.

Jump to

Keyboard shortcuts

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