Documentation ¶
Index ¶
- type Deferral
- type EtcdLocker
- func (d EtcdLocker) ClearDeferred(deferralID string) (*etcd.Response, error)
- func (d EtcdLocker) Defer(buildEvent []byte) (*etcd.Response, error)
- func (d EtcdLocker) DeferredBuilds() ([]Deferral, error)
- func (d EtcdLocker) InitDeferred() error
- func (d EtcdLocker) Key(projectKey, branch string) string
- func (d EtcdLocker) Lock(key, value string) (*etcd.Response, error)
- func (d EtcdLocker) Unlock(key, value string) (*etcd.Response, error)
- type Locker
- type NoOpLocker
- func (noop *NoOpLocker) ClearDeferred(deferralID string) (*etcd.Response, error)
- func (noop *NoOpLocker) Defer(data []byte) (*etcd.Response, error)
- func (noop *NoOpLocker) DeferredBuilds() ([]Deferral, error)
- func (noop *NoOpLocker) InitDeferred() error
- func (noop *NoOpLocker) Key(projectKey, branch string) string
- func (noop *NoOpLocker) Lock(key, value string) (*etcd.Response, error)
- func (noop *NoOpLocker) Unlock(key, value string) (*etcd.Response, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deferral ¶
type Deferral struct { // The underlying opaque build event. Data string `json:"-"` // The key under which the deferred build is stored. Key string `json:"key"` }
Deferral models a deferred build. Data is the serialized build event, while key is the identifier assigned to this deferred build by the locker service.
type EtcdLocker ¶
type EtcdLocker struct { // Config is the underlying etcd cluster configuration Config etcd.Config }
EtcdLocker is the Locker implementation on top of etcd.
func (EtcdLocker) ClearDeferred ¶
func (d EtcdLocker) ClearDeferred(deferralID string) (*etcd.Response, error)
ClearDeferred removes a build from the deferred list.
func (EtcdLocker) Defer ¶
func (d EtcdLocker) Defer(buildEvent []byte) (*etcd.Response, error)
Defer defers a build by saving it to a locker service provided key. See Atomically Creating In-Order Keys at https://coreos.com/etcd/docs/0.4.7/etcd-api/.
func (EtcdLocker) DeferredBuilds ¶
func (d EtcdLocker) DeferredBuilds() ([]Deferral, error)
DeferredBuilds returns the list of builds currently deferred.
func (EtcdLocker) InitDeferred ¶
func (d EtcdLocker) InitDeferred() error
InitDeferred creates the directory in etcd where deferred builds are stored.
func (EtcdLocker) Key ¶
func (d EtcdLocker) Key(projectKey, branch string) string
Key defines an unique, opaque key that locks a build.
type Locker ¶
type Locker interface { // Lock sets a lock in the lock service to prevent concurrent builds of a given branch Lock(key, value string) (*etcd.Response, error) // Unlock clears a lock on a build Unlock(key, value string) (*etcd.Response, error) // Defer creates an entry in the lock service that marks a build as deferred. Defer(buildEvent []byte) (*etcd.Response, error) // Clears the entry for a deferred build ClearDeferred(deferredID string) (*etcd.Response, error) // Returns the current list of deferred builds in created order DeferredBuilds() ([]Deferral, error) // Initialize the deferred build system if necessary InitDeferred() error // Form the opaque key for a given branch on a project Key(projectKey, branch string) string }
Locker defines the interface the build locker and build deferral instance makes available.
func NewEtcdLocker ¶
New returns a new etcd implementation of a Locker.
type NoOpLocker ¶
func (*NoOpLocker) ClearDeferred ¶
func (noop *NoOpLocker) ClearDeferred(deferralID string) (*etcd.Response, error)
func (*NoOpLocker) DeferredBuilds ¶
func (noop *NoOpLocker) DeferredBuilds() ([]Deferral, error)
func (*NoOpLocker) InitDeferred ¶
func (noop *NoOpLocker) InitDeferred() error
func (*NoOpLocker) Key ¶
func (noop *NoOpLocker) Key(projectKey, branch string) string