{"modulePath":"github.com/UnityTech/client-go","version":"v11.0.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package resourcelock\n\n## Constants\n\n```go\nconst (\n\tLeaderElectionRecordAnnotationKey = \"control-plane.alpha.kubernetes.io/leader\"\n\tEndpointsResourceLock             = \"endpoints\"\n\tConfigMapsResourceLock            = \"configmaps\"\n\tLeasesResourceLock                = \"leases\"\n)\n```\n\n## Functions\n\n```go\nfunc LeaderElectionRecordToLeaseSpec(ler *LeaderElectionRecord) coordinationv1.LeaseSpec\n```\n\n## Types\n\n```go\ntype ConfigMapLock struct {\n\t// ConfigMapMeta should contain a Name and a Namespace of a\n\t// ConfigMapMeta object that the LeaderElector will attempt to lead.\n\tConfigMapMeta metav1.ObjectMeta\n\tClient        corev1client.ConfigMapsGetter\n\tLockConfig    ResourceLockConfig\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (cml *ConfigMapLock) Create(ler LeaderElectionRecord) error\n```\nCreate attempts to create a LeaderElectionRecord annotation\n\n```go\nfunc (cml *ConfigMapLock) Describe() string\n```\nDescribe is used to convert details on current resource lock into a string\n\n```go\nfunc (cml *ConfigMapLock) Get() (*LeaderElectionRecord, error)\n```\nGet returns the election record from a ConfigMap Annotation\n\n```go\nfunc (cml *ConfigMapLock) Identity() string\n```\nreturns the Identity of the lock\n\n```go\nfunc (cml *ConfigMapLock) RecordEvent(s string)\n```\nRecordEvent in leader election while adding meta-data\n\n```go\nfunc (cml *ConfigMapLock) Update(ler LeaderElectionRecord) error\n```\nUpdate will update an existing annotation on a given resource.\n\n```go\ntype EndpointsLock struct {\n\t// EndpointsMeta should contain a Name and a Namespace of an\n\t// Endpoints object that the LeaderElector will attempt to lead.\n\tEndpointsMeta metav1.ObjectMeta\n\tClient        corev1client.EndpointsGetter\n\tLockConfig    ResourceLockConfig\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (el *EndpointsLock) Create(ler LeaderElectionRecord) error\n```\nCreate attempts to create a LeaderElectionRecord annotation\n\n```go\nfunc (el *EndpointsLock) Describe() string\n```\nDescribe is used to convert details on current resource lock into a string\n\n```go\nfunc (el *EndpointsLock) Get() (*LeaderElectionRecord, error)\n```\nGet returns the election record from a Endpoints Annotation\n\n```go\nfunc (el *EndpointsLock) Identity() string\n```\nreturns the Identity of the lock\n\n```go\nfunc (el *EndpointsLock) RecordEvent(s string)\n```\nRecordEvent in leader election while adding meta-data\n\n```go\nfunc (el *EndpointsLock) Update(ler LeaderElectionRecord) error\n```\nUpdate will update and existing annotation on a given resource.\n\n```go\ntype EventRecorder interface {\n\tEventf(obj runtime.Object, eventType, reason, message string, args ...interface{})\n}\n```\nEventRecorder records a change in the ResourceLock.\n\n```go\ntype Interface interface {\n\t// Get returns the LeaderElectionRecord\n\tGet() (*LeaderElectionRecord, error)\n\n\t// Create attempts to create a LeaderElectionRecord\n\tCreate(ler LeaderElectionRecord) error\n\n\t// Update will update and existing LeaderElectionRecord\n\tUpdate(ler LeaderElectionRecord) error\n\n\t// RecordEvent is used to record events\n\tRecordEvent(string)\n\n\t// Identity will return the locks Identity\n\tIdentity() string\n\n\t// Describe is used to convert details on current resource lock\n\t// into a string\n\tDescribe() string\n}\n```\nInterface offers a common interface for locking on arbitrary resources used in leader election.  The Interface is used to hide the details on specific implementations in order to allow them to change over time.  This interface is strictly for use by the leaderelection code.\n\n```go\nfunc New(lockType string, ns string, name string, coreClient corev1.CoreV1Interface, coordinationClient coordinationv1.CoordinationV1Interface, rlc ResourceLockConfig) (Interface, error)\n```\nManufacture will create a lock of a given type according to the input parameters\n\n```go\ntype LeaderElectionRecord struct {\n\t// HolderIdentity is the ID that owns the lease. If empty, no one owns this lease and\n\t// all callers may acquire. Versions of this library prior to Kubernetes 1.14 will not\n\t// attempt to acquire leases with empty identities and will wait for the full lease\n\t// interval to expire before attempting to reacquire. This value is set to empty when\n\t// a client voluntarily steps down.\n\tHolderIdentity       string      `json:\"holderIdentity\"`\n\tLeaseDurationSeconds int         `json:\"leaseDurationSeconds\"`\n\tAcquireTime          metav1.Time `json:\"acquireTime\"`\n\tRenewTime            metav1.Time `json:\"renewTime\"`\n\tLeaderTransitions    int         `json:\"leaderTransitions\"`\n}\n```\nLeaderElectionRecord is the record that is stored in the leader election annotation. This information should be used for observational purposes only and could be replaced with a random string (e.g. UUID) with only slight modification of this code. TODO(mikedanese): this should potentially be versioned\n\n```go\nfunc LeaseSpecToLeaderElectionRecord(spec *coordinationv1.LeaseSpec) *LeaderElectionRecord\n```\n\n```go\ntype LeaseLock struct {\n\t// LeaseMeta should contain a Name and a Namespace of a\n\t// LeaseMeta object that the LeaderElector will attempt to lead.\n\tLeaseMeta  metav1.ObjectMeta\n\tClient     coordinationv1client.LeasesGetter\n\tLockConfig ResourceLockConfig\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (ll *LeaseLock) Create(ler LeaderElectionRecord) error\n```\nCreate attempts to create a Lease\n\n```go\nfunc (ll *LeaseLock) Describe() string\n```\nDescribe is used to convert details on current resource lock into a string\n\n```go\nfunc (ll *LeaseLock) Get() (*LeaderElectionRecord, error)\n```\nGet returns the election record from a Lease spec\n\n```go\nfunc (ll *LeaseLock) Identity() string\n```\nreturns the Identity of the lock\n\n```go\nfunc (ll *LeaseLock) RecordEvent(s string)\n```\nRecordEvent in leader election while adding meta-data\n\n```go\nfunc (ll *LeaseLock) Update(ler LeaderElectionRecord) error\n```\nUpdate will update an existing Lease spec.\n\n```go\ntype ResourceLockConfig struct {\n\t// Identity is the unique string identifying a lease holder across\n\t// all participants in an election.\n\tIdentity string\n\t// EventRecorder is optional.\n\tEventRecorder EventRecorder\n}\n```\nResourceLockConfig common data that exists across different resource locks\n\n","path":"github.com/UnityTech/client-go/tools/leaderelection/resourcelock","name":"resourcelock","synopsis":"","isRedistributable":true}
