upstream

package
v1.0.459 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 22 Imported by: 8

Documentation

Index

Constants

View Source
const (
	StatusAgentError = "agent-error"
	StatusError      = "error"
	StatusOK         = "ok"
	StatusLabel      = "status"
	AgentLabel       = "agent"
)
View Source
const AgentNameQueryParam = "agent_name"

AgentNameQueryParam is the name of the query param that's used to authenticate an agent when using basic auth instead of access tokens.

View Source
const (
	// EventPushQueueDelete is fired when a record, on one of the the tables we're tracking,
	// is hard deleted.
	EventPushQueueDelete = "push_queue.delete"
)

Variables

This section is empty.

Functions

func AgentAuthMiddleware added in v1.0.356

func AgentAuthMiddleware(agentCache *cache.Cache) func(echo.HandlerFunc) echo.HandlerFunc

func DeleteFromUpstream added in v1.0.283

func DeleteFromUpstream(ctx context.Context, config UpstreamConfig, events []postq.Event) []postq.Event

DeleteFromUpstream sends a delete request to the upstream server for the given events.

func DeleteHandler added in v1.0.283

func DeleteHandler(c echo.Context) error

PushHandler returns an echo handler that deletes the push data from the upstream.

func DeleteOnUpstream added in v1.0.283

func DeleteOnUpstream(ctx context.Context, req *PushData) error

DeleteOnUpstream deletes the given resources by agent on the upstream.

func GetOrCreateAgent added in v1.0.274

func GetOrCreateAgent(ctx context.Context, name string) (*models.Agent, error)

func InsertUpstreamMsg added in v1.0.274

func InsertUpstreamMsg(ctx context.Context, req *PushData) error

func NewDeleteFromUpstreamConsumer added in v1.0.283

func NewDeleteFromUpstreamConsumer(config UpstreamConfig) func(ctx context.Context, events postq.Events) postq.Events

NewDeleteFromUpstreamConsumer acts as an adapter to supply DeleteFromUpstream event consumer.

func PingHandler added in v1.0.337

func PingHandler(c echo.Context) error

func PushHandler added in v1.0.274

func PushHandler(c echo.Context) error

PushHandler returns an echo handler that saves the push data from agents.

func ReconcileAll added in v1.0.362

func ReconcileAll(ctx context.Context, config UpstreamConfig, batchSize int) (int, error)

func ReconcileSome added in v1.0.362

func ReconcileSome(ctx context.Context, config UpstreamConfig, batchSize int, runOnly ...string) (int, error)

func UpdateAgentLastReceived added in v1.0.337

func UpdateAgentLastReceived(ctx context.Context, id uuid.UUID) error

func UpdateAgentLastSeen added in v1.0.337

func UpdateAgentLastSeen(ctx context.Context, id uuid.UUID) error

Types

type GroupedPushEvents added in v1.0.188

type GroupedPushEvents struct {
	TableName string
	ItemIDs   [][]string
	Events    postq.Events
}

func GroupChangelogsByTables added in v1.0.188

func GroupChangelogsByTables(events []postq.Event) []GroupedPushEvents

GroupChangelogsByTables groups the given events by the table they belong to.

type PushData

type PushData struct {
	Canaries                     []models.Canary                      `json:"canaries,omitempty"`
	Checks                       []models.Check                       `json:"checks,omitempty"`
	Components                   []models.Component                   `json:"components,omitempty"`
	ConfigScrapers               []models.ConfigScraper               `json:"config_scrapers,omitempty"`
	ConfigAnalysis               []models.ConfigAnalysis              `json:"config_analysis,omitempty"`
	ConfigChanges                []models.ConfigChange                `json:"config_changes,omitempty"`
	ConfigItems                  []models.ConfigItem                  `json:"config_items,omitempty"`
	CheckStatuses                []models.CheckStatus                 `json:"check_statuses,omitempty"`
	ConfigRelationships          []models.ConfigRelationship          `json:"config_relationships,omitempty"`
	ComponentRelationships       []models.ComponentRelationship       `json:"component_relationships,omitempty"`
	ConfigComponentRelationships []models.ConfigComponentRelationship `json:"config_component_relationships,omitempty"`
	Topologies                   []models.Topology                    `json:"topologies,omitempty"`
	PlaybookActions              []models.PlaybookRunAction           `json:"playbook_actions,omitempty"`
	Artifacts                    []models.Artifact                    `json:"artifacts,omitempty"`
}

PushData consists of data about changes to components, configs, analysis.

func NewPushData added in v1.0.362

func NewPushData[T models.DBTable](records []T) *PushData

func (*PushData) AddMetrics added in v1.0.317

func (p *PushData) AddMetrics(counter context.Counter)

func (*PushData) ApplyLabels

func (t *PushData) ApplyLabels(labels map[string]string)

ApplyLabels injects additional labels to the suitable fields

func (*PushData) Attributes added in v1.0.205

func (p *PushData) Attributes() map[string]any

func (*PushData) Count

func (t *PushData) Count() int

func (*PushData) PopulateAgentID

func (t *PushData) PopulateAgentID(id uuid.UUID)

PopulateAgentID sets agent_id on all the data

func (*PushData) ReplaceTopologyID

func (t *PushData) ReplaceTopologyID(id *uuid.UUID)

ReplaceTopologyID replaces the topology_id for all the components with the provided id.

func (*PushData) String

func (p *PushData) String() string

type PushFKError added in v1.0.428

type PushFKError struct {
	IDs []string `json:"ids"`
}

type UpstreamClient added in v1.0.192

type UpstreamClient struct {
	AgentName string
	*http.Client
}

func NewUpstreamClient added in v1.0.192

func NewUpstreamClient(config UpstreamConfig) *UpstreamClient

func (*UpstreamClient) Delete added in v1.0.283

func (t *UpstreamClient) Delete(ctx context.Context, msg *PushData) error

Delete performs hard delete on the given items from the upstream server.

func (*UpstreamClient) Ping added in v1.0.337

func (t *UpstreamClient) Ping(ctx context.Context) error

Ping sends a ping message to the upstream

func (*UpstreamClient) Push added in v1.0.192

func (t *UpstreamClient) Push(ctx context.Context, msg *PushData) error

Push uploads the given push message to the upstream server.

func (*UpstreamClient) PushArtifacts added in v1.0.316

func (t *UpstreamClient) PushArtifacts(ctx context.Context, artifactID uuid.UUID, reader io.ReadCloser) error

PushArtifacts uploads the given artifact to the upstream server.

type UpstreamConfig

type UpstreamConfig struct {
	AgentName          string
	Host               string
	InsecureSkipVerify bool
	Username           string
	Password           string
	Labels             []string
	Debug              bool
	Options            []func(c *http.Client)
}

func (*UpstreamConfig) IsPartiallyFilled

func (t *UpstreamConfig) IsPartiallyFilled() (bool, error)

func (*UpstreamConfig) LabelsMap

func (t *UpstreamConfig) LabelsMap() map[string]string

func (UpstreamConfig) String added in v1.0.259

func (t UpstreamConfig) String() string

func (*UpstreamConfig) Valid

func (t *UpstreamConfig) Valid() bool

Jump to

Keyboard shortcuts

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