activity

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	NetworkActivityMimeType = mimetype.ApplicationMsgPack
)

Variables

View Source
var (
	ErrMissingTopic   = errors.New("missing activity topic")
	ErrInvalidWindow  = errors.New("aggregation window must be greater than 0")
	ErrUnknownNetwork = errors.New("unknown network, expected testnet, mainnet, or rvasp")
)
View Source
var NetworkActivityEventType = api.Type{
	Name:         "NetworkActivity",
	MajorVersion: 1,
}

Functions

func Reset

func Reset()

Reset the publisher to allow NewPublisher() to be called again, this method should only be used for testing.

func SetClient

func SetClient(newClient *ensign.Client)

Set an Ensign client for testing purposes.

func Start

func Start(conf Config) (err error)

Start the global activity publisher from the configuration.

func Stop

func Stop()

Stop the publisher and wait for the goroutine to exit.

Types

type Activity

type Activity uint16
const (
	UnknownActivity Activity = iota
	LookupActivity
	SearchActivity
	RegisterActivity
	KeyExchangeActivity
)

func (Activity) String

func (a Activity) String() string

type ActivityCount

type ActivityCount map[Activity]uint64

type Config

type Config struct {
	Enabled           bool          `split_words:"true" default:"false"`
	Topic             string        `split_words:"true"`
	Network           Network       `split_words:"true"`
	AggregationWindow time.Duration `split_words:"true" default:"5m"`
	Testing           bool          `split_words:"true" default:"false"`
	Ensign            ensign.Config
}

func (Config) Validate

func (c Config) Validate() (err error)

type Entry

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

Entries are created from external go routines and are eventually published as Events to Ensign by the activity publisher.

func KeyExchange

func KeyExchange() *Entry

KeyExchange creates a new activity entry for fetching a signing key. Must call Add() to commit the entry.

func Lookup

func Lookup() *Entry

Lookup creates a new activity entry for a lookup. Must call Add() to commit the entry.

func Register

func Register() *Entry

Register creates a new activity entry for registering a VASP. Must call Add() to commit the entry.

func Search() *Entry

Search creates a new activity entry for a search. Must call Add() to commit the entry.

func (*Entry) Add

func (e *Entry) Add()

Add the activity entry to the publisher.

func (*Entry) VASP

func (e *Entry) VASP(id string) *Entry

VASP adds a VASP UUID to the event.

type Network

type Network uint8
const (
	UnknownNetwork Network = iota
	TestNet
	MainNet
	RVASP
)

func (*Network) Decode

func (n *Network) Decode(s string) error

func (Network) String

func (n Network) String() string

func (Network) Validate

func (n Network) Validate() error

type NetworkActivity

type NetworkActivity struct {
	Network      Network                  `msgpack:"network"`       // The network refers to TestNet or MainNet and possibly also rVASP
	Activity     ActivityCount            `msgpack:"activity"`      // A count of activity events by name
	VASPActivity map[string]ActivityCount `msgpack:"vasp_activity"` // Per-vasp activity count should be less than or equal to activity counts
	Timestamp    time.Time                `msgpack:"timestamp"`     // The start time of the aggregation window
	Window       time.Duration            `msgpack:"window"`        // The window size of the aggregation window
}

NetworkActivity represents a time-aggregated collection of events on the GDS or rVASP that are a proxy for TRISA transfer usage; e.g. GDS lookups or rVSAP transfers. This event is published as msgpack data to an Ensign topic so that the BFF can render a timeseries of network activity.

func New

func New(network Network, window time.Duration, ts time.Time) *NetworkActivity

func Parse

func Parse(event *ensign.Event) (_ *NetworkActivity, err error)

func (*NetworkActivity) Event

func (a *NetworkActivity) Event() (_ *ensign.Event, err error)

func (*NetworkActivity) Incr

func (a *NetworkActivity) Incr(activity Activity)

func (*NetworkActivity) IncrVASP

func (a *NetworkActivity) IncrVASP(vaspID string, activity Activity)

func (*NetworkActivity) Reset

func (a *NetworkActivity) Reset()

Reset the activity counts to zero in preparation for a new aggregation window.

func (*NetworkActivity) WindowEnd

func (a *NetworkActivity) WindowEnd() time.Time

func (*NetworkActivity) WindowStart

func (a *NetworkActivity) WindowStart() time.Time

Jump to

Keyboard shortcuts

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