cffetcher

package
v0.143.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultRecordMinAge = 5 * time.Minute
	DefaultFetchLimit   = 50
)
View Source
const GUIDNil = "GUID_NIL"

GUIDNil represents an empty GUID

Variables

This section is empty.

Functions

This section is empty.

Types

type CFEventFetcher

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

CFEventFetcher is an EventFetcher that fetches cloudfoundry App or Service usage events

func New

func New(cfg Config) (*CFEventFetcher, error)

New creates a new CFEventFetcher for the given config

func (*CFEventFetcher) FetchEvents

func (e *CFEventFetcher) FetchEvents(ctx context.Context, lastEvent *eventio.RawEvent) ([]eventio.RawEvent, error)

FetchEvents requests

func (*CFEventFetcher) Kind

func (e *CFEventFetcher) Kind() string

Kind returns the type of event this fetcher returns

type Config

type Config struct {
	// Type sets the Kind of event to collect, must be App or Service
	Type Kind
	// ClientConfig allows configuration of connection to CF API
	ClientConfig *cfclient.Config
	// Client overrides the default client used to query API
	Client UsageEventsAPI
	// Logger overrides the default logger
	Logger lager.Logger
	// RecordMinAge sets the age at which events are mature enough for collection
	RecordMinAge time.Duration
	// FetchLimit dictates the max number of events returned in each FetchEvents call
	FetchLimit int
}

FetcherConfig allows tuning of the fetcher. You must set a Type and ClientConfig

type Kind

type Kind string
const (
	App     Kind = "app"
	Service Kind = "service"
)

type MetaData

type MetaData struct {
	GUID      string    `json:"guid"`
	CreatedAt time.Time `json:"created_at"`
}

MetaData contains the record metadata like id and creation date

type UsageEvent

type UsageEvent struct {
	MetaData  MetaData
	EntityRaw json.RawMessage `json:"entity"`
}

UsageEvent represent a usage event record from the API

type UsageEventList

type UsageEventList struct {
	Resources []UsageEvent `json:"resources"`
}

UsageEventList contains usage event records

type UsageEventsAPI

type UsageEventsAPI interface {
	Get(afterGUID string, count int, minAge time.Duration) (*UsageEventList, error)
	Type() string
}

UsageEventsAPI is a common interface for the app and service usage event APIs

func NewAppUsageEventsAPI

func NewAppUsageEventsAPI(client UsageEventsClient, logger lager.Logger) UsageEventsAPI

NewAppUsageEventsAPI returns with a new app usage events API client

func NewServiceUsageEventsAPI

func NewServiceUsageEventsAPI(client UsageEventsClient, logger lager.Logger) UsageEventsAPI

NewServiceUsageEventsAPI returns with a new service usage events API client

type UsageEventsClient

type UsageEventsClient interface {
	Get(path string) (*http.Response, error)
}

UsageEventsClient is a general Cloud Foundry API client interface

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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