Documentation
¶
Index ¶
- type State
- func (st *State) FilterUnitUUIDsForApplication(ctx context.Context, units []unit.UUID, app coreapplication.ID) (set.Strings, error)
- func (s *State) GetAllOpenedPorts(ctx context.Context) (port.UnitGroupedPortRanges, error)
- func (st *State) GetApplicationOpenedPorts(ctx context.Context, application coreapplication.ID) (port.UnitEndpointPortRanges, error)
- func (st *State) GetMachineNamesForUnits(ctx context.Context, units []unit.UUID) ([]coremachine.Name, error)
- func (st *State) GetMachineOpenedPorts(ctx context.Context, machine string) (map[coreunit.Name]network.GroupedPortRanges, error)
- func (st *State) GetUnitOpenedPorts(ctx context.Context, unit coreunit.UUID) (network.GroupedPortRanges, error)
- func (st *State) GetUnitUUID(ctx context.Context, unitName coreunit.Name) (coreunit.UUID, error)
- func (st *State) InitialWatchMachineOpenedPortsStatement() string
- func (st *State) UpdateUnitPorts(ctx context.Context, unit coreunit.UUID, ...) error
- func (st *State) WatchOpenedPortsTable() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type State ¶
State represents the persistence layer for opened ports.
func NewState ¶
func NewState(factory database.TxnRunnerFactory) *State
NewState returns a new state reference.
func (*State) FilterUnitUUIDsForApplication ¶
func (*State) GetAllOpenedPorts ¶
GetAllOpenedPorts returns the opened ports in the model, grouped by unit name.
NOTE: We do not group by endpoint here. It is not needed. Instead, we just group by unit name
func (*State) GetApplicationOpenedPorts ¶
func (st *State) GetApplicationOpenedPorts(ctx context.Context, application coreapplication.ID) (port.UnitEndpointPortRanges, error)
GetApplicationOpenedPorts returns the opened ports for all the units of the given application. We return opened ports paired with the unit UUIDs, grouped by endpoint. This is because some consumers do not care about the unit.
func (*State) GetMachineNamesForUnits ¶
func (st *State) GetMachineNamesForUnits(ctx context.Context, units []unit.UUID) ([]coremachine.Name, error)
GetMachineNamesForUnits returns a slice of machine names that host the provided units.
func (*State) GetMachineOpenedPorts ¶
func (st *State) GetMachineOpenedPorts(ctx context.Context, machine string) (map[coreunit.Name]network.GroupedPortRanges, error)
GetMachineOpenedPorts returns the opened ports for all the units on the given machine. Opened ports are grouped first by unit and then by endpoint.
NOTE: In the ddl machines and units both share 1-to-1 relations with net_nodes. So to join units to machines we go via their net_nodes.
TODO: Once we have a core static machine uuid type, use it here.
func (*State) GetUnitOpenedPorts ¶
func (st *State) GetUnitOpenedPorts(ctx context.Context, unit coreunit.UUID) (network.GroupedPortRanges, error)
GetUnitOpenedPorts returns the opened ports for a given unit uuid, grouped by endpoint.
func (*State) GetUnitUUID ¶
GetUnitUUID returns the UUID of the unit with the given name, returning an error satisfying porterrors.UnitNotFound if the unit does not exist.
func (*State) InitialWatchMachineOpenedPortsStatement ¶
InitialWatchMachineOpenedPortsStatement returns the query to load the initial event for the WatchOpenedPorts watcher
func (*State) UpdateUnitPorts ¶
func (st *State) UpdateUnitPorts( ctx context.Context, unit coreunit.UUID, openPorts, closePorts network.GroupedPortRanges, ) error
UpdateUnitPorts opens and closes ports for the endpoints of a given unit. The service layer must ensure that opened and closed ports for the same endpoints must not conflict.
func (*State) WatchOpenedPortsTable ¶
WatchOpenedPortsTable returns the name of the table that should be watched