client

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceQueryArgName is the name of the query parameter
	ServiceQueryArgName = "service"
	// InstanceIDQueryArgName is the name of the query parameter
	InstanceIDQueryArgName = "instance_id"
	// TenantIDQueryArgName is the name of the query parameter
	TenantIDQueryArgName = "tenant_id"
	// BaseTimeQueryArgName is the name of the query parameter
	BaseTimeQueryArgName = "base_time"
	// EventCountQueryArgName is the name of the query parameter
	EventCountQueryArgName = "event_count"
	// FilterQueryArgName is the name of the query parameter
	FilterQueryArgName = "query"
)
View Source
const (
	// InstancesHandlerPath is the name of the URL segment
	InstancesHandlerPath = "/logserver/instances"
	// ActivityHandlerPath is the name of the URL segment
	ActivityHandlerPath = "/logserver/activity"
	// ChartQueryHandlerPath is the name of the URL segment
	ChartQueryHandlerPath = "/logserver/query"
	// RawLogsHandlerPath is the name of the URL segment
	RawLogsHandlerPath = "/logserver/kinesis"
	// CountersHandlerPath is the name of the URL segment
	CountersHandlerPath = "/logserver/counters"
	// EventMetadataPath is the name of the URL segment
	EventMetadataPath = "/logserver/eventmetadata"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chart

type Chart struct {
	Cols []ColsType `json:"cols"`
	Rows []RowType  `json:"rows"`
}

Chart is Google Chart standard type

type Client

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

Client represents a client to talk to the UserClouds LogServer service

func NewClient

func NewClient(url string, tenantID uuid.UUID, opts ...jsonclient.Option) (*Client, error)

NewClient constructs a new LogServer client

func NewClientForTenant added in v0.7.2

func NewClientForTenant(tenantURL string, tenantID uuid.UUID, clientID, clientSecret string, opts ...jsonclient.Option) (*Client, error)

NewClientForTenant constructs a new LogServer client using the provided client ID & secret to authenticate

func (*Client) CreateEventType

func (c *Client) CreateEventType(ctx context.Context, service string, instanceID uuid.UUID, tenantID uuid.UUID, eventDef *[]MetricMetadata) (*[]MetricMetadata, error)

CreateEventType create a new event metadata type

func (*Client) CreateEventTypesForTenant

func (c *Client) CreateEventTypesForTenant(ctx context.Context, service string, instanceID uuid.UUID, tenantID uuid.UUID, eventDef *[]MetricMetadata) (*[]MetricMetadata, error)

CreateEventTypesForTenant create a new event metadata type

func (*Client) DeleteEventTypeForReferenceURLForTenant

func (c *Client) DeleteEventTypeForReferenceURLForTenant(ctx context.Context, instanceID uuid.UUID, referenceURL string, tenantID uuid.UUID) error

DeleteEventTypeForReferenceURLForTenant deletes all the custom events types for the reference object for given tenant

func (*Client) DeleteEventTypesForReferenceURL

func (c *Client) DeleteEventTypesForReferenceURL(ctx context.Context, instanceID uuid.UUID, referenceURL string) error

DeleteEventTypesForReferenceURL deletes all the custom events types for the reference object

func (*Client) GetCharts

func (c *Client) GetCharts(ctx context.Context, queries *[]CounterQuery) (*[]Chart, error)

GetCharts gets event counts for given event types/timeperiod

func (*Client) GetEventTypes

func (c *Client) GetEventTypes(ctx context.Context, referenceURL string) (*[]MetricMetadata, error)

GetEventTypes gets a list of event sources generating events /instances

func (*Client) GetEventTypesTenant

func (c *Client) GetEventTypesTenant(ctx context.Context, referenceURL string, tenantID uuid.UUID) (*[]MetricMetadata, error)

GetEventTypesTenant gets a list of event sources generating events /instances

func (*Client) GetSources

func (c *Client) GetSources(ctx context.Context) (*[]SourceRecord, error)

GetSources gets a list of event sources generating events /instances

func (*Client) GetSourcesForTenant

func (c *Client) GetSourcesForTenant(ctx context.Context, tenantID uuid.UUID) (*[]SourceRecord, error)

GetSourcesForTenant gets a list of event sources generating events /instances

func (*Client) ListCounterRecords

func (c *Client) ListCounterRecords(ctx context.Context, service string, count int) (*[]CounterRecord, error)

ListCounterRecords gets a list of events for a time period/service (/activity)

func (*Client) ListCounterRecordsForTenant

func (c *Client) ListCounterRecordsForTenant(ctx context.Context, service string, count int, tenantID uuid.UUID) (*[]CounterRecord, error)

ListCounterRecordsForTenant gets a list of events for a time period/service (/activity)

func (*Client) PostCounters

func (c *Client) PostCounters(ctx context.Context, service string, instanceID uuid.UUID, baseTime time.Time, counters *map[uuid.UUID]map[string]int) (*LogTransportSettings, error)

PostCounters posts a set of events for a time period (/counters)

func (*Client) PostRawLogs

func (c *Client) PostRawLogs(ctx context.Context, service string, instanceID uuid.UUID, messages *map[uuid.UUID][][]byte) (*LogTransportSettings, error)

PostRawLogs posts a set of log messages (/kinesis)

type ColsType

type ColsType struct {
	ID      string `json:"id"`
	Label   string `json:"label"`
	Pattern string `json:"pattern"`
	Type    string `json:"type"`
}

ColsType is Google Chart standard Cols type

type CounterQuery

type CounterQuery struct {
	TenantID  uuid.UUID     `json:"tenant_id"`
	Service   string        `json:"service"`
	EventType []int         `json:"event_codes"`
	Start     time.Time     `json:"start"`
	End       time.Time     `json:"end"`
	Period    time.Duration `json:"period"`
}

CounterQuery describes a query to the server which generates a raw chart data TODO: this should be shared with logserver/.../countersbackend

type CounterRecord

type CounterRecord struct {
	ID        uint64 `json:"id"`
	EventName string `json:"event_name"`
	EventType string `json:"event_type"`
	Service   string `json:"service"`
	Timestamp int64  `json:"timestamp"`
	Count     int    `json:"count"`
}

CounterRecord provides data for row in the event log

type LogTransportSettings

type LogTransportSettings struct {
	Update           bool
	SendRawData      bool
	LogLevel         uclog.LogLevel
	MessageInterval  int
	CountersInterval int
}

LogTransportSettings is sent by the server to update local transport settings

type MetricAttributes

type MetricAttributes struct {
	// Ignore indicate that the client shouldn't send this event to the server
	Ignore bool `db:"ignore" json:"ignore"`
	// System indicate that this is a system (UC) event and not per object event
	System bool `db:"system" json:"system"`
	// AnyService indicate that this is event can be triggered by any service
	AnyService bool `db:"anyservice" json:"anyservice"`
}

MetricAttributes contains set of attribues

type MetricMetadata

type MetricMetadata struct {
	ucdb.BaseModel

	// Service in which this event occurs
	Service service.Service `db:"service" json:"service"`
	// Category is the category of the event
	Category uclog.EventCategory `db:"category" json:"category"`
	// NameString is the name the client will pass if it doesn't have the code
	StringID string `db:"string_id" json:"string_id"`
	// Unique numeric code for the event, stays same across namestring changes
	Code uclog.EventCode `db:"code" json:"code"`
	// URL to object this events relates to if available
	ReferenceURL string `db:"url" json:"url"`
	// Human readable name for the event
	Name string `db:"name" json:"name"`
	// Description for what the event represents
	Description string `db:"description" json:"description"`
	// Attributes for the event
	Attributes MetricAttributes `db:"attributes" json:"attributes"`
}

MetricMetadata describes metadata for an event

type RowCType

type RowCType struct {
	V interface{} `json:"v"`
	F interface{} `json:"f"`
}

RowCType is Google Chart standard Rows.C type

type RowType

type RowType struct {
	C []RowCType `json:"c"`
}

RowType is Google Chart standard Rows type

type SourceRecord

type SourceRecord struct {
	InstanceID           uuid.UUID      `json:"instance_id"`
	LastTenantID         uuid.UUID      `json:"last_tenant_id"`
	Multitenant          bool           `json:"multitenant"`
	Service              string         `json:"service"`
	Region               string         `json:"region"`
	CodeVersion          string         `json:"code_version"`
	StartupTime          time.Time      `json:"startup_time"`
	EventMetadataVersion int            `json:"event_metadata_version"`
	LastActivity         time.Time      `json:"last_activity"`
	CallCount            int            `json:"call_count"`
	EventCount           int            `json:"event_count"`
	ErrorInternalCount   int            `json:"error_internal_count"`
	ErrorInputCount      int            `json:"error_input_count"`
	SendRawData          bool           `json:"send_raw_data"`
	LogLevel             uclog.LogLevel `json:"log_level"`
	MessageInterval      int            `json:"message_interval"`
	CountersInterval     int            `json:"counters_interval"`
	ProcessedStartup     bool           `json:"processed_startup"`
}

SourceRecord contains information about a "running" instance of service that has registired with the server and can send events

Jump to

Keyboard shortcuts

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