mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
firewalldb: put Action DB methods behind an interface
So that we can easily add a different implementation and swop them out later.
This commit is contained in:
parent
9b3349b31e
commit
ec3b38f607
3 changed files with 26 additions and 2 deletions
|
|
@ -230,7 +230,7 @@ func (db *BoltDB) GetActionsReadDB(groupID session.ID,
|
|||
|
||||
// allActionsReadDb is an implementation of the ActionsReadDB.
|
||||
type allActionsReadDB struct {
|
||||
db *BoltDB
|
||||
db ActionDB
|
||||
groupID session.ID
|
||||
featureName string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,3 +100,27 @@ type PrivacyMapper interface {
|
|||
// given group ID key.
|
||||
PrivacyDB(groupID session.ID) PrivacyMapDB
|
||||
}
|
||||
|
||||
// ActionDB is an interface that abstracts the database operations needed for
|
||||
// the Action persistence and querying.
|
||||
type ActionDB interface {
|
||||
// AddAction persists the given action to the database.
|
||||
AddAction(action *Action) (uint64, error)
|
||||
|
||||
// SetActionState finds the action specified by the ActionLocator and
|
||||
// sets its state to the given state.
|
||||
SetActionState(al *ActionLocator, state ActionState,
|
||||
errReason string) error
|
||||
|
||||
// ListActions returns a list of Actions that pass the filterFn
|
||||
// requirements. The query IndexOffset and MaxNum params can be used to
|
||||
// control the number of actions returned. The return values are the
|
||||
// list of actions, the last index and the total count (iff
|
||||
// query.CountTotal is set).
|
||||
ListActions(ctx context.Context, query *ListActionsQuery,
|
||||
options ...ListActionOption) ([]*Action, uint64, uint64, error)
|
||||
|
||||
// GetActionsReadDB produces an ActionReadDB using the given group ID
|
||||
// and feature name.
|
||||
GetActionsReadDB(groupID session.ID, featureName string) ActionsReadDB
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ type sessionRpcServerConfig struct {
|
|||
superMacBaker litmac.Baker
|
||||
firstConnectionDeadline time.Duration
|
||||
permMgr *perms.Manager
|
||||
actionsDB *firewalldb.BoltDB
|
||||
actionsDB firewalldb.ActionDB
|
||||
autopilot autopilotserver.Autopilot
|
||||
ruleMgrs rules.ManagerSet
|
||||
privMap firewalldb.PrivacyMapper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue