notifications

package
v0.28.8-beta Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Subsystem = "NTFNS"

Subsystem defines the sub system name of this package.

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Client

type Client interface {
	// SubscribeNotifications subscribes to the notifications from the server.
	SubscribeNotifications(ctx context.Context,
		in *swapserverrpc.SubscribeNotificationsRequest,
		opts ...grpc.CallOption) (
		swapserverrpc.SwapServer_SubscribeNotificationsClient, error)
}

Client is the interface that the notification manager needs to implement in order to be able to subscribe to notifications.

type Config

type Config struct {
	// Client is the client used to communicate with the swap server.
	Client Client

	// FetchL402 is the function used to fetch the l402 token.
	FetchL402 func(context.Context) error
}

Config contains all the services that the notification manager needs to operate.

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Manager is a manager for notifications that the swap server sends to the client.

func NewManager

func NewManager(cfg *Config) *Manager

NewManager creates a new notification manager.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

Run starts the notification manager. It will keep on running until the context is canceled. It will subscribe to notifications and forward them to the subscribers. On a first successful connection to the server, it will close the readyChan to signal that the manager is ready.

func (*Manager) SubscribeReservations

func (m *Manager) SubscribeReservations(ctx context.Context,
) <-chan *swapserverrpc.ServerReservationNotification

SubscribeReservations subscribes to the reservation notifications.

type NotificationType

type NotificationType int

NotificationType is the type of notification that the manager can handle.

const (
	// NotificationTypeUnknown is the default notification type.
	NotificationTypeUnknown NotificationType = iota

	// NotificationTypeReservation is the notification type for reservation
	// notifications.
	NotificationTypeReservation
)

Jump to

Keyboard shortcuts

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