Documentation ¶
Overview ¶
Package poller provides a interfaces for polling and consuming proxy configuration objects from the Turbine Labs API
Index ¶
- Constants
- type Consumer
- type FromFlags
- type MockConsumer
- type MockConsumerMockRecorder
- type MockFromFlags
- type MockFromFlagsMockRecorder
- type MockPoller
- type MockPollerMockRecorder
- type MockRegistrar
- type MockRegistrarMockRecorder
- type MockRemote
- type MockRemoteMockRecorder
- type Objects
- func (co *Objects) AggregateRules(rt api.Route) []TaggedRule
- func (co *Objects) AllPorts() []int
- func (co *Objects) CheckIntegrity() error
- func (co *Objects) ClusterFromKey(key api.ClusterKey) api.Cluster
- func (co *Objects) DomainsPerPort(port int) api.Domains
- func (co *Objects) Init()
- func (co *Objects) ListenerForPort(port int) *api.Listener
- func (co *Objects) RoutesPerDomain(domainKey api.DomainKey) api.Routes
- func (co *Objects) SharedRulesFromKey(key api.SharedRulesKey) api.SharedRules
- func (co *Objects) SubsetsPerCluster(clusterKey api.ClusterKey) [][]string
- func (co *Objects) TerribleHash() string
- type ObjectsUpdateFn
- type Poller
- type Registrar
- type Remote
- type TaggedRule
Constants ¶
const FixtureHash = "io1y1O1a2jFYogy9yaNY8A=="
FixtureHash is the expected result calling TerribleHash() on the *Objects produced by MkFixtureObjects()
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FromFlags ¶
type FromFlags interface { Validate() error Make(service.All, Consumer, Registrar, stats.Stats) Poller }
FromFlags produces a Poller from flag-based configuration
func NewFromFlags ¶
NewFromFlags produces a FromFlags, and installs necessary configuration flags into the provided FlagSet.
type MockConsumer ¶
type MockConsumer struct {
// contains filtered or unexported fields
}
MockConsumer is a mock of Consumer interface
func NewMockConsumer ¶
func NewMockConsumer(ctrl *gomock.Controller) *MockConsumer
NewMockConsumer creates a new mock instance
func (*MockConsumer) Consume ¶
func (m *MockConsumer) Consume(arg0 *Objects) error
Consume mocks base method
func (*MockConsumer) EXPECT ¶
func (m *MockConsumer) EXPECT() *MockConsumerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockConsumerMockRecorder ¶
type MockConsumerMockRecorder struct {
// contains filtered or unexported fields
}
MockConsumerMockRecorder is the mock recorder for MockConsumer
func (*MockConsumerMockRecorder) Consume ¶
func (mr *MockConsumerMockRecorder) Consume(arg0 interface{}) *gomock.Call
Consume indicates an expected call of Consume
type MockFromFlags ¶
type MockFromFlags struct {
// contains filtered or unexported fields
}
MockFromFlags is a mock of FromFlags interface
func NewMockFromFlags ¶
func NewMockFromFlags(ctrl *gomock.Controller) *MockFromFlags
NewMockFromFlags creates a new mock instance
func (*MockFromFlags) EXPECT ¶
func (m *MockFromFlags) EXPECT() *MockFromFlagsMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockFromFlags) Make ¶
func (m *MockFromFlags) Make(arg0 service.All, arg1 Consumer, arg2 Registrar, arg3 stats.Stats) Poller
Make mocks base method
func (*MockFromFlags) Validate ¶
func (m *MockFromFlags) Validate() error
Validate mocks base method
type MockFromFlagsMockRecorder ¶
type MockFromFlagsMockRecorder struct {
// contains filtered or unexported fields
}
MockFromFlagsMockRecorder is the mock recorder for MockFromFlags
func (*MockFromFlagsMockRecorder) Make ¶
func (mr *MockFromFlagsMockRecorder) Make(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
Make indicates an expected call of Make
func (*MockFromFlagsMockRecorder) Validate ¶
func (mr *MockFromFlagsMockRecorder) Validate() *gomock.Call
Validate indicates an expected call of Validate
type MockPoller ¶
type MockPoller struct {
// contains filtered or unexported fields
}
MockPoller is a mock of Poller interface
func NewMockPoller ¶
func NewMockPoller(ctrl *gomock.Controller) *MockPoller
NewMockPoller creates a new mock instance
func (*MockPoller) EXPECT ¶
func (m *MockPoller) EXPECT() *MockPollerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockPollerMockRecorder ¶
type MockPollerMockRecorder struct {
// contains filtered or unexported fields
}
MockPollerMockRecorder is the mock recorder for MockPoller
func (*MockPollerMockRecorder) Close ¶
func (mr *MockPollerMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close
func (*MockPollerMockRecorder) Poll ¶
func (mr *MockPollerMockRecorder) Poll() *gomock.Call
Poll indicates an expected call of Poll
func (*MockPollerMockRecorder) PollLoop ¶
func (mr *MockPollerMockRecorder) PollLoop() *gomock.Call
PollLoop indicates an expected call of PollLoop
type MockRegistrar ¶
type MockRegistrar struct {
// contains filtered or unexported fields
}
MockRegistrar is a mock of Registrar interface
func NewMockRegistrar ¶
func NewMockRegistrar(ctrl *gomock.Controller) *MockRegistrar
NewMockRegistrar creates a new mock instance
func (*MockRegistrar) Deregister ¶
func (m *MockRegistrar) Deregister(pRef service.ProxyRef, ifLast func()) error
Deregister mocks base method
func (*MockRegistrar) EXPECT ¶
func (m *MockRegistrar) EXPECT() *MockRegistrarMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockRegistrar) Refs ¶
func (m *MockRegistrar) Refs() []service.ProxyRef
Refs mocks base method
type MockRegistrarMockRecorder ¶
type MockRegistrarMockRecorder struct {
// contains filtered or unexported fields
}
MockRegistrarMockRecorder is the mock recorder for MockRegistrar
func (*MockRegistrarMockRecorder) Deregister ¶
func (mr *MockRegistrarMockRecorder) Deregister(pRef, ifLast interface{}) *gomock.Call
Deregister indicates an expected call of Deregister
func (*MockRegistrarMockRecorder) Refs ¶
func (mr *MockRegistrarMockRecorder) Refs() *gomock.Call
Refs indicates an expected call of Refs
func (*MockRegistrarMockRecorder) Register ¶
func (mr *MockRegistrarMockRecorder) Register(pRef, ifFirst interface{}) *gomock.Call
Register indicates an expected call of Register
type MockRemote ¶
type MockRemote struct {
// contains filtered or unexported fields
}
MockRemote is a mock of Remote interface
func NewMockRemote ¶
func NewMockRemote(ctrl *gomock.Controller) *MockRemote
NewMockRemote creates a new mock instance
func (*MockRemote) EXPECT ¶
func (m *MockRemote) EXPECT() *MockRemoteMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockRemote) Objects ¶
func (m *MockRemote) Objects(proxyKey api.ProxyKey) (*Objects, error)
Objects mocks base method
func (*MockRemote) ObjectsWithOverrides ¶
func (m *MockRemote) ObjectsWithOverrides(proxyKey api.ProxyKey, overrides map[string]ObjectsUpdateFn, newProxy *api.Proxy) (*Objects, error)
ObjectsWithOverrides mocks base method
type MockRemoteMockRecorder ¶
type MockRemoteMockRecorder struct {
// contains filtered or unexported fields
}
MockRemoteMockRecorder is the mock recorder for MockRemote
func (*MockRemoteMockRecorder) Objects ¶
func (mr *MockRemoteMockRecorder) Objects(proxyKey interface{}) *gomock.Call
Objects indicates an expected call of Objects
func (*MockRemoteMockRecorder) ObjectsWithOverrides ¶
func (mr *MockRemoteMockRecorder) ObjectsWithOverrides(proxyKey, overrides, newProxy interface{}) *gomock.Call
ObjectsWithOverrides indicates an expected call of ObjectsWithOverrides
type Objects ¶
type Objects struct { Zone api.Zone `json:"zone"` Proxy api.Proxy `json:"proxy"` Clusters []api.Cluster `json:"clusters"` Domains api.Domains `json:"domains"` Listeners api.Listeners `json:"listeners"` Routes []api.Route `json:"routes"` Checksum api.Checksum `json:"checksum"` // contains filtered or unexported fields }
Objects represents the api.Clusters, api.Domains, and api.Routes needed to construct a tbnproxy config file using a template.
func MkFixtureObjects ¶
func MkFixtureObjects() *Objects
MkFixtureObjects produces a *Objects that exercises most of the surface area of the API, suitable for testing.
func (*Objects) AggregateRules ¶
func (co *Objects) AggregateRules(rt api.Route) []TaggedRule
AggregateRules returns a computed rule set for a given route that combines the Rules inherited from the referenced SharedRules and the Route-specific rules defined locally.
func (*Objects) CheckIntegrity ¶
CheckIntegrity makes sure that no non-existant Domains or Clusters are referenced in co.Routes or co.SharedRules. Assumes no change to the Objects after initial construction.
func (*Objects) ClusterFromKey ¶
func (co *Objects) ClusterFromKey(key api.ClusterKey) api.Cluster
ClusterFromKey returns the Cluster object associated with the specified ClusterKey. This is only for use by a config template and should not be used to determine if a given ClusterKey is present in the Clusters slice.
func (*Objects) DomainsPerPort ¶
DomainsPerPort returns the list of Domains which have the given port
func (*Objects) ListenerForPort ¶
ListenerForPort returns the listener for the given port
func (*Objects) RoutesPerDomain ¶
RoutesPerDomain returns all routes associated with the given DomainKey
func (*Objects) SharedRulesFromKey ¶
func (co *Objects) SharedRulesFromKey(key api.SharedRulesKey) api.SharedRules
SharedRulesFromKey returns the SharedRules object associated with a given key. This is only used by config templates. Panics if the SharedRulesKey does not resolve to a valid SharedRules object.
func (*Objects) SubsetsPerCluster ¶
func (co *Objects) SubsetsPerCluster(clusterKey api.ClusterKey) [][]string
SubsetsPerCluster returns a list of sets of metadata keys corresponding to distinct Match/ClusterConstraint pairs for the given Cluster.
func (*Objects) TerribleHash ¶
TerribleHash returns a string that can be used for equality comparison between two Objects. It is computed once, and will not track changes to the Objects.
type ObjectsUpdateFn ¶
type ObjectsUpdateFn func(*Objects)
ObjectsUpdateFn is a type alias for a function that operates on an *Objects
type Poller ¶
type Poller interface { // Poll will perform a single iteration that will produce objects that are // pushed to a Consumer. It may update internal state during the iteration. Poll() error // PollLoop polls for changes to the configuration objects of a Proxy in an // infinite loop, logging errors. Closing the Poller signals the loop to exit. PollLoop() // Close causes PollLoop to exit. Close() error }
Poller polls for the configuration objects of a Proxy.
type Registrar ¶
type Registrar interface { // Register a proxy. ifFirst is called synchronously if the proxy was not // registered by anyone else before the call. ifFirst is called within the // critical section; as such calling Register or Deregister from within // ifFirst is forbidden. Register(pRef service.ProxyRef, ifFirst func(service.All, api.Proxy)) error // Deregister a proxy. ifLast is called synchronously if the proxy is no longer // registered by anyone after the call. ifLast is called within the // critical section; as such calling Register or Deregister from within // ifLast is forbidden. Deregister(pRef service.ProxyRef, ifLast func()) error // Refs returns the list of currently registered proxies Refs() []service.ProxyRef }
Registrar allows consumers to declare what proxies they're interesting in getting *Objects for.
func NewDelayedRegistrar ¶
NewDelayedRegistrar returns a Registrar that delays Deregistration by the specified interval. Deregeistration failures are logged to console.Error but otherwise ignored.
func NewNopRegistrar ¶
func NewNopRegistrar() Registrar
NewNopRegistrar returns a Registrar that does nothing, and returns the given proxy refs
type Remote ¶
type Remote interface { Objects(proxyKey api.ProxyKey) (*Objects, error) // ObjectsWithOverrides returns the *Objects for a given ProxyKey. If a // function exists in the map corresponding to the key of an object (cast as a // string) that exists in the *Objects being constructed, that function will // be invoked on the *Objects before proceeding to the next step of the object // graph walk. If a proxy is being created then newProxy will be used as the // starting point for the validation. ObjectsWithOverrides( proxyKey api.ProxyKey, overrides map[string]ObjectsUpdateFn, newProxy *api.Proxy, ) (*Objects, error) }
Remote is an adapter to the Turbine API for obtaining ConfigObjects for a Proxy Config.
func NewRemoteFromFns ¶
func NewRemoteFromFns( zoneGet func(api.ZoneKey) (api.Zone, error), proxyGet func(api.ProxyKey) (api.Proxy, error), domainIndex func(...service.DomainFilter) (api.Domains, error), listenerIndex func(...service.ListenerFilter) (api.Listeners, error), routeIndex func(...service.RouteFilter) (api.Routes, error), sharedRulesIndex func(...service.SharedRulesFilter) (api.SharedRulesSlice, error), sharedRulesGet func(api.SharedRulesKey) (api.SharedRules, error), clusterIndex func(...service.ClusterFilter) (api.Clusters, error), ) Remote
NewRemoteFromFns returns a Remote backed by the specified function pointers.
type TaggedRule ¶
TaggedRule represents a rule that has been aggregated from the Rules of a Route and the Rules of its SharedRules.