reservmgr

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2022 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPolicyID = "default"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Opts

type Opts struct {
	// The datastore path of the reservation manager.
	Path string
}

Opts is the options for reservation manager.

type ReservationManager

type ReservationManager interface {
	// SetDefaultPolicy sets the default reservation policy.
	//
	// @input - context, currency id, if unlimited reservation, maximum single reservation amount.
	//
	// @output - error.
	SetDefaultPolicy(ctx context.Context, currencyID byte, unlimited bool, max *big.Int) error

	// GetDefaultPolicy gets the default reservation policy.
	//
	// @input - context, currency id.
	//
	// @output - if unlimited, max single reservation amount, error.
	GetDefaultPolicy(ctx context.Context, currencyID byte) (bool, *big.Int, error)

	// RemoveDefaultPolicy removes the default reservation policy.
	//
	// @input - context, currency id.
	//
	// @output - error.
	RemoveDefaultPolicy(ctx context.Context, currencyID byte) error

	// SetPaychPolicy sets the reservation policy for a given paych.
	//
	// @input - context, currency id, channel address, if unlimited reservation, maximum single reservation amount.
	//
	// @output - error.
	SetPaychPolicy(ctx context.Context, currencyID byte, chAddr string, unlimited bool, max *big.Int) error

	// GetPaychPolicy gets the reservation policy for a given paych.
	//
	// @input - context, currency id, channel address.
	//
	// @output - if unlimited reservation, maximum single reservation amount, error.
	GetPaychPolicy(ctx context.Context, currencyID byte, chAddr string) (bool, *big.Int, error)

	// RemovePaychPolicy removes the reservation policy for a given paych.
	//
	// @input - context, currency id, channel address.
	//
	// @output - error.
	RemovePaychPolicy(ctx context.Context, currencyID byte, chAddr string) error

	// SetPeerPolicy sets the reservation policy for a given peer.
	//
	// @input - context, currency id, channel address, peer address, if unlimited reservation, maximum single reservation amount.
	//
	// @output - error.
	SetPeerPolicy(ctx context.Context, currencyID byte, chAddr string, peerAddr string, unlimited bool, max *big.Int) error

	// GetPeerPolicy gets the reservation policy for a given peer.
	//
	// @input - context, currency id, channel address, peer address.
	//
	// @output - if unlimited reservation, maximum single reservation amount, error.
	GetPeerPolicy(ctx context.Context, currencyID byte, chAddr string, peerAddr string) (bool, *big.Int, error)

	// RemovePeerPolicy removes the reservation policy for a given peer.
	//
	// @input - context, currency id, channel address, peer address.
	//
	// @output - error.
	RemovePeerPolicy(ctx context.Context, currencyID byte, chAddr string, peerAddr string) error

	// ListCurrencyIDs lists all currency ids.
	//
	// @input - context.
	//
	// @output - currency id chan out, error chan out.
	ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error)

	// ListPaychs lists all paychs.
	//
	// @input - context, currency id.
	//
	// @output - paych chan out, error chan out.
	ListPaychs(ctx context.Context, currencyID byte) (<-chan string, <-chan error)

	// ListPeers lists all peers.
	//
	// @input - context, currency id, paych address.
	//
	// @output - peer chan out, error chan out.
	ListPeers(ctx context.Context, currencyID byte, chAddr string) (<-chan string, <-chan error)
}

ReservationManager is the interface for a manager that is used to manage all reservation policy. If a policy has a maximum of 0, it means the policy is to reject.

type ReservationManagerImpl

type ReservationManagerImpl struct {
	// contains filtered or unexported fields
}

ReservationManagerImpl is the implementation of the ReservationManager interface.

func NewReservationManagerImpl

func NewReservationManagerImpl(ctx context.Context, opts Opts) (*ReservationManagerImpl, error)

NewReservationManagerImpl creates a new ReservationManagerImpl.

@input - context, options.

@output - reservation manager, error.

func (*ReservationManagerImpl) GetDefaultPolicy

func (s *ReservationManagerImpl) GetDefaultPolicy(ctx context.Context, currencyID byte) (bool, *big.Int, error)

GetDefaultPolicy gets the default reservation policy.

@input - context, currency id.

@output - if unlimited, max single reservation amount, error.

func (*ReservationManagerImpl) GetPaychPolicy

func (s *ReservationManagerImpl) GetPaychPolicy(ctx context.Context, currencyID byte, chAddr string) (bool, *big.Int, error)

GetPaychPolicy gets the reservation policy for a given paych.

@input - context, currency id, channel address.

@output - if unlimited reservation, maximum single reservation amount, error.

func (*ReservationManagerImpl) GetPeerPolicy

func (s *ReservationManagerImpl) GetPeerPolicy(ctx context.Context, currencyID byte, chAddr string, peerAddr string) (bool, *big.Int, error)

GetPeerPolicy gets the reservation policy for a given peer.

@input - context, currency id, channel address, peer address.

@output - if unlimited reservation, maximum single reservation amount, error.

func (*ReservationManagerImpl) ListCurrencyIDs

func (s *ReservationManagerImpl) ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error)

ListCurrencyIDs lists all currency ids.

@input - context.

@output - currency id chan out, error chan out.

func (*ReservationManagerImpl) ListPaychs

func (s *ReservationManagerImpl) ListPaychs(ctx context.Context, currencyID byte) (<-chan string, <-chan error)

ListPaychs lists all paychs.

@input - context, currency id.

@output - paych chan out, error chan out.

func (*ReservationManagerImpl) ListPeers

func (s *ReservationManagerImpl) ListPeers(ctx context.Context, currencyID byte, chAddr string) (<-chan string, <-chan error)

ListPeers lists all peers.

@input - context, currency id, paych address.

@output - peer chan out, error chan out.

func (*ReservationManagerImpl) RemoveDefaultPolicy

func (s *ReservationManagerImpl) RemoveDefaultPolicy(ctx context.Context, currencyID byte) error

RemoveDefaultPolicy removes the default reservation policy.

@input - context, currency id.

@output - error.

func (*ReservationManagerImpl) RemovePaychPolicy

func (s *ReservationManagerImpl) RemovePaychPolicy(ctx context.Context, currencyID byte, chAddr string) error

RemovePaychPolicy removes the reservation policy for a given paych.

@input - context, currency id, channel address.

@output - error.

func (*ReservationManagerImpl) RemovePeerPolicy

func (s *ReservationManagerImpl) RemovePeerPolicy(ctx context.Context, currencyID byte, chAddr string, peerAddr string) error

RemovePeerPolicy removes the reservation policy for a given peer.

@input - context, currency id, channel address, peer address.

@output - error.

func (*ReservationManagerImpl) SetDefaultPolicy

func (s *ReservationManagerImpl) SetDefaultPolicy(ctx context.Context, currencyID byte, unlimited bool, max *big.Int) error

SetDefaultPolicy sets the default reservation policy.

@input - context, currency id, if unlimited reservation, maximum single reservation amount.

@output - error.

func (*ReservationManagerImpl) SetPaychPolicy

func (s *ReservationManagerImpl) SetPaychPolicy(ctx context.Context, currencyID byte, chAddr string, unlimited bool, max *big.Int) error

SetPaychPolicy sets the reservation policy for a given paych.

@input - context, currency id, channel address, if unlimited reservation, maximum single reservation amount.

@output - error.

func (*ReservationManagerImpl) SetPeerPolicy

func (s *ReservationManagerImpl) SetPeerPolicy(ctx context.Context, currencyID byte, chAddr string, peerAddr string, unlimited bool, max *big.Int) error

SetPeerPolicy sets the reservation policy for a given peer.

@input - context, currency id, channel address, peer address, if unlimited reservation, maximum single reservation amount.

@output - error.

func (*ReservationManagerImpl) Shutdown

func (s *ReservationManagerImpl) Shutdown()

Shutdown safely shuts down the component.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL