notifier

package
v0.0.0-...-07a5409 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0, MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotifierPollInterval = time.Second * 30

Functions

func DidSync

func DidSync(head, prev ipld.Link) bool

func GetLastAdvertisement

func GetLastAdvertisement(ctx context.Context, client *ipnifind.Client, provider peer.ID) (ipld.Link, error)

Types

type HeadState

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

func NewHeadState

func NewHeadState(ds store.Store, hostname string) (*HeadState, error)

func (*HeadState) Get

func (h *HeadState) Get(ctx context.Context) ipld.Link

func (*HeadState) Set

func (h *HeadState) Set(ctx context.Context, head ipld.Link) error

type Notifier

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

func NewNotifierWithStorage

func NewNotifierWithStorage(addr string, id crypto.PrivKey, store store.Store) (*Notifier, error)

func NewRemoteSyncNotifier

func NewRemoteSyncNotifier(addr string, id crypto.PrivKey, head NotifierHead) (*Notifier, error)

NewRemoteSyncNotifier creates an IPNI sync notifier instance that calls notification functions when a remote IPNI instance has performed a sync and it's latest advertisement has changed. The head parameter is optional.

Note: not guaranteed to notify for every sync event.

func (*Notifier) Notify

func (n *Notifier) Notify(f NotifyRemoteSyncFunc)

func (*Notifier) Start

func (n *Notifier) Start(ctx context.Context)

func (*Notifier) Stop

func (n *Notifier) Stop()

func (*Notifier) Update

func (n *Notifier) Update(ctx context.Context) (bool, time.Time, error)

type NotifierHead

type NotifierHead interface {
	Get(context.Context) ipld.Link
	Set(context.Context, ipld.Link) error
}

type NotifyRemoteSyncFunc

type NotifyRemoteSyncFunc func(ctx context.Context, head, prev ipld.Link)

NotifyRemoteSyncFunc is a function that is called when a remote IPNI node has been seen to perform a sync.

type RemoteSyncNotifier

type RemoteSyncNotifier interface {
	// Notify adds the passed notification function to the list of functions that
	// should be called when a remote IPNI node has been seen to perform a sync.
	Notify(NotifyRemoteSyncFunc)
}

RemoteSyncNotifier enables notifications of remote sync events.

Jump to

Keyboard shortcuts

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