juju: github.com/juju/juju/apiserver/facades/agent/leadership Index | Files

package leadership

import "github.com/juju/juju/apiserver/facades/agent/leadership"

Index

Package Files

interface.go leadership.go settings.go

Constants

const (
    // FacadeName is the string-representation of this API used both
    // to register the service, and for the client to resolve the
    // service endpoint.
    FacadeName = "LeadershipService"

    // MinLeaseRequest is the shortest duration for which we will accept
    // a leadership claim.
    MinLeaseRequest = 5 * time.Second

    // MaxLeaseRequest is the longest duration for which we will accept
    // a leadership claim.
    MaxLeaseRequest = 5 * time.Minute
)

type GetSettingsFn Uses

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 Uses

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 Uses

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 Uses

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

NewLeadershipService constructs a new LeadershipService.

func NewLeadershipServiceFacade Uses

func NewLeadershipServiceFacade(context facade.Context) (LeadershipService, error)

NewLeadershipServiceFacade constructs a new LeadershipService and presents a signature that can be used for facade registration.

type LeadershipSettingsAccessor Uses

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

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

func NewLeadershipSettingsAccessor Uses

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

NewLeadershipSettingsAccessor creates a new LeadershipSettingsAccessor.

func (*LeadershipSettingsAccessor) Merge Uses

func (lsa *LeadershipSettingsAccessor) Merge(bulkArgs params.MergeLeadershipSettingsBulkParams) (params.ErrorResults, error)

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

func (*LeadershipSettingsAccessor) Read Uses

func (lsa *LeadershipSettingsAccessor) Read(bulkArgs params.Entities) (params.GetLeadershipSettingsBulkResults, error)

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

func (*LeadershipSettingsAccessor) WatchLeadershipSettings Uses

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 Uses

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

MergeSettingsChunk 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 Uses

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

SettingsChangeNotifierFn 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.

Package leadership imports 8 packages (graph) and is imported by 4 packages. Updated 2019-08-23. Refresh now. Tools for package owners.