github.com/Pankov404/juju@v0.0.0-20150703034450-be266991dceb/worker/uniter/relation/hookqueue.go (about)

     1  // Copyright 2012-2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package relation
     5  
     6  import (
     7  	"github.com/juju/juju/state/multiwatcher"
     8  	"github.com/juju/juju/worker/uniter/hook"
     9  )
    10  
    11  // HookQueue exists to keep the package interface stable.
    12  type HookQueue interface {
    13  	hook.Sender
    14  }
    15  
    16  // NewAliveHookQueue exists to keep the package interface stable; it wraps the
    17  // result of NewLiveHookSource in a HookSender.
    18  func NewAliveHookQueue(initial *State, out chan<- hook.Info, w RelationUnitsWatcher) HookQueue {
    19  	source := NewLiveHookSource(initial, w)
    20  	return hook.NewSender(out, source)
    21  }
    22  
    23  // NewDyingHookQueue exists to keep the package interface stable; it wraps the
    24  // result of NewDyingHookSource in a HookSender.
    25  func NewDyingHookQueue(initial *State, out chan<- hook.Info) HookQueue {
    26  	source := NewDyingHookSource(initial)
    27  	return hook.NewSender(out, source)
    28  }
    29  
    30  // RelationUnitsWatcher produces RelationUnitsChange events until stopped, or
    31  // until it encounters an error. It must not close its Changes channel without
    32  // signalling an error via Stop and Err.
    33  type RelationUnitsWatcher interface {
    34  	Err() error
    35  	Stop() error
    36  	Changes() <-chan multiwatcher.RelationUnitsChange
    37  }