Documentation
¶
Index ¶
- func BuildRouteValue(desired map[string]*WeightedBackend) string
- type CollectedBackendIntents
- type DynamicMapUpdates
- type EntryKey
- type EntryValue
- type IntentValue
- type MapData
- type MapFileState
- func (m *MapFileState) ApplyDesiredBackends(entryKey EntryKey, resourceOrigin ResourceOrigin, ...)
- func (m *MapFileState) ApplyRoute(ro ResourceOrigin, newEntries map[EntryKey]map[string]*WeightedBackend)
- func (m *MapFileState) PrettyString() string
- func (m *MapFileState) ProcessMapFiles()
- func (m *MapFileState) Reset()
- func (m *MapFileState) WriteOnDiskIfChanged() error
- type Operation
- type PresentOperations
- type ResourceOrigin
- type WeightedBackend
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRouteValue ¶ added in v0.9.0
func BuildRouteValue(desired map[string]*WeightedBackend) string
Types ¶
type CollectedBackendIntents ¶ added in v0.9.0
type CollectedBackendIntents struct {
Weight *int32
PresentOperations
}
func (CollectedBackendIntents) String ¶ added in v0.9.0
func (cbi CollectedBackendIntents) String() string
type DynamicMapUpdates ¶
type DynamicMapUpdates struct {
// ToAdd contains the entries to add to the map
Add map[string]string
Update map[string]string
// ToDelete contains the entries to delete from the map
Delete []string
}
DynamicMapUpdates contains the updates to be applied to the map on runtime (and to have diff)
type EntryValue ¶ added in v0.9.0
type EntryValue struct {
// IntentsByBackendByResouceOrigin map[ResourceOrigin]*IntentValue
IntentsByBackendByResouceOrigin map[ResourceOrigin]map[string]*IntentValue // resource origin -> backend name -> backend + weight
CurrentValue map[string]*WeightedBackend // backend name -> backend + weight
DiffValue map[string]*IntentValue // backend name -> backend + weight + operation (useful for sockets orders)
DesiredValue map[string]*WeightedBackend // backend name -> backend + weight
}
EntryValue represents all the information necessary to compute the desired state for a given key in the map file
func (EntryValue) CopyDesiredValue ¶ added in v0.9.0
func (ev EntryValue) CopyDesiredValue() map[string]*WeightedBackend
func (*EntryValue) PrettyString ¶ added in v0.9.0
func (ev *EntryValue) PrettyString(indent string) string
type IntentValue ¶ added in v0.9.0
type IntentValue struct {
WeightedBackend
Operation
}
func (IntentValue) Copy ¶ added in v0.9.0
func (i IntentValue) Copy() *IntentValue
func (IntentValue) String ¶ added in v0.9.0
func (i IntentValue) String() string
type MapData ¶
type MapData struct {
// Path is set only if the map was saved on disk (this is a gate configuration)
// For HUG, maps are stored on disk
Path futils.FilePath
// Dynamic updates through runtime
DynamicUpdates DynamicMapUpdates
// ReloadNeeded is managed only if the gate library did try to run a runtime command (this is a gate configuration)
// For HUG, the gate library will try to create/update/delete maps through runtime
// By default, it is set to true
// If the gate library did try to update the maps through runtime (create/update/delete), and a reload is not needed
// as the runtime command did succeed, then the flag is set to false
ReloadNeeded bool
// contains filtered or unexported fields
}
func (*MapData) AddData ¶
AddData adds a key-value pair to the map If the key already exists, the value is updated
func (*MapData) DeleteData ¶
DeleteData deletes a key from the map
type MapFileState ¶ added in v0.9.0
type MapFileState struct {
// The contents of the map file.
// Could be in the format: hostname+path ou sni-> backend
Entries map[EntryKey]*EntryValue
EntriesByResource map[ResourceOrigin]map[EntryKey]struct{}
FileName string
RelativeFileName string
// contains filtered or unexported fields
}
func NewMapFileState ¶ added in v0.9.0
func NewMapFileState(relativeMapPath, mapFilePath string, logger *slog.Logger) *MapFileState
NewMapFileState creates a new instance of MapFileState with the given filename and logger. It returns a pointer to the new instance.
func (*MapFileState) ApplyDesiredBackends ¶ added in v0.9.0
func (m *MapFileState) ApplyDesiredBackends( entryKey EntryKey, resourceOrigin ResourceOrigin, desired map[string]*WeightedBackend, )
ApplyDesiredBackends applies the desired backends for an entry and resource origin to the map file state. It handles four cases: 1. Get/Create EntryValue 2. Get the intents for all backends from this resource origin 3. DELETE : present before, absent now 4. CREATE / UPDATE / NOOP
func (*MapFileState) ApplyRoute ¶ added in v0.9.0
func (m *MapFileState) ApplyRoute( ro ResourceOrigin, newEntries map[EntryKey]map[string]*WeightedBackend, )
ApplyRoute applies a set of new entries to the MapFileState and updates the EntriesByResource accordingly. It handles three cases: 1. Apply / update for all new entries 2. Handle removed entries (previous but not in new) 3. Update EntriesByResource
func (*MapFileState) PrettyString ¶ added in v0.9.0
func (m *MapFileState) PrettyString() string
func (*MapFileState) ProcessMapFiles ¶ added in v0.9.0
func (m *MapFileState) ProcessMapFiles()
ProcessMapFiles processes the map file and updates the desired values based on the intent operations stored in the map file state. It iterates over each entry/intent for the filename and collects the operations for each backend name. It then fills the desired values with the current values and updates the diff values with the desired operations. Finally, it prints the map file state after processing.
func (*MapFileState) Reset ¶ added in v0.9.0
func (m *MapFileState) Reset()
Reset resets the MapFileState to its initial state. It deletes all the entries with their corresponding functions and resources. It also resets the DesiredValue and diffValue of each entry to their initial state. It is intended to be used after a map file has been processed and its contents have been applied to the runtime maps.
func (*MapFileState) WriteOnDiskIfChanged ¶ added in v0.9.0
func (m *MapFileState) WriteOnDiskIfChanged() error
WriteOnDiskIfChanged writes the MapFileState to disk if there are any differences between the desired state and the current state. It iterates over the entries in the map file state and checks if there are any differences between the desired state and the current state. If there are differences, it writes the desired state to disk in the format "key value\n"
type PresentOperations ¶ added in v0.9.0
Collect all intentions for each backend Each order has a precedence order Create & Update > Delete
type ResourceOrigin ¶ added in v0.9.0
func (ResourceOrigin) String ¶ added in v0.9.0
func (ro ResourceOrigin) String() string
type WeightedBackend ¶ added in v0.9.0
func (WeightedBackend) Copy ¶ added in v0.9.0
func (wb WeightedBackend) Copy() *WeightedBackend
func (WeightedBackend) String ¶ added in v0.9.0
func (wb WeightedBackend) String() string