subs

package
v0.0.0-...-891dfff Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Subscribe

func Subscribe(fetcher Fetcher) *sub

Types

type ComponentFetcher

type ComponentFetcher struct {
	// Url is the endpoint to hit during a fetch request
	Url string
	// Interval is the polling interval for every fetch
	// TODO: (MT) Support various formats such as:
	// `10s`, `2m`, `1h`, `1h20m3s` etc
	Interval time.Duration
}

func Fetch

func Fetch(url string, interval time.Duration) *ComponentFetcher

func (*ComponentFetcher) Fetch

func (sf *ComponentFetcher) Fetch() (interface{}, time.Time, error)

type Fetcher

type Fetcher interface {
	Fetch() (interface{}, time.Time, error)
}

type PluginConfig

type PluginConfig struct {
	Id       string            `json:"id"`
	Name     string            `json:"name"`
	Url      string            `json:"url"`
	Method   string            `json:"method"`
	Headers  map[string]string `json:"headers"`
	Interval string            `json:"interval"`
}

type SimpleFetcher

type SimpleFetcher struct {
	// Url is the endpoint to hit during a fetch request
	Url string
	// Interval is the polling interval for every fetch
	// TODO: (MT) Support various formats such as:
	// `10s`, `2m`, `1h`, `1h20m3s` etc
	Interval time.Duration
}

func (*SimpleFetcher) Fetch

func (sf *SimpleFetcher) Fetch() (interface{}, time.Time, error)

type Subscription

type Subscription interface {
	Updates() <-chan interface{}
	Close() error
}

func Merge

func Merge(subscriptions []Subscription) Subscription

Jump to

Keyboard shortcuts

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