renewmgr

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 renew manager.
	Path string
}

Opts is the options for renew manager.

type RenewManager

type RenewManager interface {
	// SetDefaultPolicy sets the default renew policy.
	//
	// @input - context, currency id, renew duration.
	//
	// @output - error.
	SetDefaultPolicy(ctx context.Context, currencyID byte, duration time.Duration) error

	// GetDefaultPolicy gets the default renew policy.
	//
	// @input - context, currency id.
	//
	// @output - renew duration, error.
	GetDefaultPolicy(ctx context.Context, currencyID byte) (time.Duration, error)

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

	// SetSenderPolicy sets a renew policy for a given sender.
	//
	// @input - context, currency id, payment channel sender, renew duration.
	//
	// @output - error.
	SetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string, duration time.Duration) error

	// GetSenderPolicy gets the policy for a given currency id and sender pair.
	//
	// @input - context, currency id, payment channel sender.
	//
	// @output - renew duration, error.
	GetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) (time.Duration, error)

	// RemoveSenderPolicy removes a policy.
	//
	// @input - context, currency id, payment channel sender.
	//
	// @output - error.
	RemoveSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) error

	// SetPaychPolicy sets a renew policy for a given paych.
	//
	// @input - context, currency id, payment channel sender, paych addr, renew duration.
	//
	// @output - error.
	SetPaychPolicy(ctx context.Context, currencyID byte, fromAddr string, chAddr string, duration time.Duration) error

	// GetPaychPolicy gets the policy for a given currency id and paych pair.
	//
	// @input - context, currency id, payment channel sender, paych addr.
	//
	// @output - renew duration, error.
	GetPaychPolicy(ctx context.Context, currencyID byte, fromAddr string, chAddr string) (time.Duration, error)

	// RemoveSenderPolicy removes a policy.
	//
	// @input - context, currency id, payment channel sender, paych addr.
	//
	// @output - error.
	RemovePaychPolicy(ctx context.Context, currencyID byte, fromAddr string, chAddr 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)

	// ListSenders lists all senders with a policy set.
	//
	// @input - context, currency id.
	//
	// @output - sender chan out (could be default policy id or sender addr), error chan out.
	ListSenders(ctx context.Context, currencyID byte) (<-chan string, <-chan error)

	// ListSenders lists all paychs with a policy set.
	//
	// @input - context, currency id, sender addr.
	//
	// @output - paych addr chan out (could be default policy id or paych addr), error chan out.
	ListPaychs(ctx context.Context, currencyID byte, fromAddr string) (<-chan string, <-chan error)
}

RenewManager is the interface for a manager that is used to manage all renew period policies. If a policy has a duration of 0, it means the policy is to reject.

type RenewManagerImpl

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

RenewManagerImpl is the implementation of the RenewManager interface.

func NewRenewManagerImpl

func NewRenewManagerImpl(ctx context.Context, opts Opts) (*RenewManagerImpl, error)

NewRenewManagerImpl creates a new RenewManagerImpl.

@input - context, options.

@output - renew manager, error.

func (*RenewManagerImpl) GetDefaultPolicy

func (s *RenewManagerImpl) GetDefaultPolicy(ctx context.Context, currencyID byte) (time.Duration, error)

GetDefaultPolicy gets the default renew policy.

@input - context, currency id.

@output - renew duration, error.

func (*RenewManagerImpl) GetPaychPolicy

func (s *RenewManagerImpl) GetPaychPolicy(ctx context.Context, currencyID byte, fromAddr string, chAddr string) (time.Duration, error)

GetPaychPolicy gets the policy for a given currency id and paych pair.

@input - context, currency id, payment channel sender, paych addr.

@output - renew duration, error.

func (*RenewManagerImpl) GetSenderPolicy

func (s *RenewManagerImpl) GetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) (time.Duration, error)

GetSenderPolicy gets the policy for a given currency id and sender pair.

@input - context, currency id, payment channel sender.

@output - renew duration, error.

func (*RenewManagerImpl) ListCurrencyIDs

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

ListCurrencyIDs lists all currency ids.

@input - context.

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

func (*RenewManagerImpl) ListPaychs

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

ListSenders lists all paychs with a policy set.

@input - context, currency id, sender addr.

@output - paych addr chan out (could be default policy id or paych addr), error chan out.

func (*RenewManagerImpl) ListSenders

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

ListSenders lists all senders with a policy set.

@input - context, currency id.

@output - sender chan out (could be default policy id or sender addr), error chan out.

func (*RenewManagerImpl) RemoveDefaultPolicy

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

RemoveDefaultPolicy removes the default renew policy.

@input - context, currency id.

@output - error.

func (*RenewManagerImpl) RemovePaychPolicy

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

RemoveSenderPolicy removes a policy.

@input - context, currency id, payment channel sender, paych addr.

@output - error.

func (*RenewManagerImpl) RemoveSenderPolicy

func (s *RenewManagerImpl) RemoveSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) error

RemoveSenderPolicy removes a policy.

@input - context, currency id, payment channel sender.

@output - error.

func (*RenewManagerImpl) SetDefaultPolicy

func (s *RenewManagerImpl) SetDefaultPolicy(ctx context.Context, currencyID byte, duration time.Duration) error

SetDefaultPolicy sets the default renew policy.

@input - context, currency id, renew duration.

@output - error.

func (*RenewManagerImpl) SetPaychPolicy

func (s *RenewManagerImpl) SetPaychPolicy(ctx context.Context, currencyID byte, fromAddr string, chAddr string, duration time.Duration) error

SetPaychPolicy sets a renew policy for a given paych.

@input - context, currency id, payment channel sender, paych addr, renew duration.

@output - error.

func (*RenewManagerImpl) SetSenderPolicy

func (s *RenewManagerImpl) SetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string, duration time.Duration) error

SetSenderPolicy sets a renew policy for a given sender.

@input - context, currency id, payment channel sender, renew duration.

@output - error.

func (*RenewManagerImpl) Shutdown

func (s *RenewManagerImpl) 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