Documentation ¶
Index ¶
- Variables
- func RDeps(serviceList []string, allServices []habpkg.HabPkg, binds Binds) ([]habpkg.HabPkg, error)
- func TopoSort(serviceList []string, allServices []habpkg.HabPkg, binds Binds) ([]habpkg.HabPkg, error)
- func TopoSortAll(services []habpkg.HabPkg, binds Binds) ([]habpkg.HabPkg, error)
- type Bind
- type BindLookup
- type BindModeMap
- type Bindmap
- type Binds
- type Collection
- type Info
- type ReverseBinds
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotEnoughParams is returned from ParseData when the data does // not contain the required number of fields to construct a bind // argument. ErrNotEnoughParams = errors.New("Not enough parameters provided") // ErrUnknownBindType is returned from ParseData when the data // includes a Bind type other than Required or Optional. ErrUnknownBindType = errors.New("Unknown bind type") )
Functions ¶
func TopoSort ¶
func TopoSort(serviceList []string, allServices []habpkg.HabPkg, binds Binds) ([]habpkg.HabPkg, error)
TopoSort is like TopoSortAll but only returns the nodes in allServices reachable from the nodes identified in services.
func TopoSortAll ¶
TopoSortAll topologically sorts the slice of service packages based on the given binds data. It returns a slice of sorted HabPkgs. If error is non-nil there is a dependency cycle.
The service list and dependency information is passed separately rather than using a more standard adjacency list representation simply to save on data-munging (services and binds are parsed separately currently)
This uses a "depth-first" approach. It uses more memory than it needs to to facilitate nice errors and a bit of programming ease.
Types ¶
type Bind ¶
type Bind struct {
// contains filtered or unexported fields
}
Bind represents a bind name and a service group it is bound to
func (Bind) ServiceGroup ¶
ServiceGroup returns the service group
type BindLookup ¶
type BindModeMap ¶
BindModeMap maps components to their binding modes
type Binds ¶
type Binds struct { Optional Bindmap Required Bindmap BindMode BindModeMap }
Binds is a type that holds optional and required bindings for all components
func (*Binds) AllForService ¶
AllForService returns a list of all binds (both optional and non-optional) for a service.
func (*Binds) DefaultsForService ¶
DefaultsForService is a helper function that returns a BindInfo struct for the given service.
The returned BindSpecs assume that all binds should be mapped to the service of the same name in the default group.
An error is returned if any of the assumptions are violated:
- All services must specify a binding mode
func (*Binds) ToReverseBinds ¶
func (b *Binds) ToReverseBinds() *ReverseBinds
type Collection ¶
type Collection struct {
Binds []Bind
}
Collection is a set of binds
func (Collection) Equal ¶
func (xs Collection) Equal(ys Collection) bool
Equal compares 2 sets of Binds for equality
type Info ¶
type Info struct { // Specs is an array of strings in the form of // BIND:SERVICE_GROUP, each representing a bind->service_group // map that that can be passed to Habitat. Specs []string // Mode is a bind mode. Must be non-empty if len(Specs) > 0 Mode string }
Info contains the bind information for a single service required for interaction with Habitat. Right now this is lossy and we lose required vs optional bind information.
type ReverseBinds ¶
type ReverseBinds struct {
// contains filtered or unexported fields
}
ReverseBinds holds reverse bind dependencies, ignoring the optional vs required distinction.
func (*ReverseBinds) AllForService ¶
func (r *ReverseBinds) AllForService(name string) []string