upstream

package
v1.0.317 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 23 Imported by: 8

Documentation

Index

Constants

View Source
const (
	StatusAgentError = "agent-error"
	StatusError      = "error"
	StatusOK         = "ok"
	StatusLabel      = "status"
	AgentLabel       = "agent"
)
View Source
const (
	EventPushQueueCreate = "push_queue.create"

	// 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 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(agentIDCache *cache.Cache) func(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 NewPushUpstreamConsumer added in v1.0.265

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

getPushUpstreamConsumer acts as an adapter to supply PushToUpstream event consumer.

func PullHandler added in v1.0.274

func PullHandler(allowedTables []string) func(echo.Context) error

PullHandler returns a handler that returns all the ids of items it has received from the requested agent.

func PushHandler added in v1.0.274

func PushHandler(agentIDCache *cache.Cache) func(echo.Context) error

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

func PushToUpstream added in v1.0.188

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

PushToUpstream fetches records specified in events from this instance and sends them to the upstream instance.

func StatusHandler added in v1.0.274

func StatusHandler(allowedTables []string) func(echo.Context) error

StatusHandler returns a handler that returns the summary of all ids the upstream has received.

func SyncArtifacts added in v1.0.309

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

SyncArtifacts pushes artifacts that haven't already been pushed to upstream.

func SyncCheckStatuses added in v1.0.195

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

SyncCheckStatuses pushes check statuses, that haven't already been pushed, to upstream.

func SyncConfigAnalyses added in v1.0.274

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

SyncConfigAnalyses pushes config analyses, that haven't already been pushed, to upstream.

func SyncConfigChanges added in v1.0.274

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

SyncConfigChanges pushes config changes, that haven't already been pushed, to upstream.

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 PaginateRequest

type PaginateRequest struct {
	Table string `query:"table"`
	From  string `query:"from"`
	Size  int    `query:"size"`
}

func (PaginateRequest) String added in v1.0.259

func (p PaginateRequest) String() string

type PaginateResponse

type PaginateResponse struct {
	Hash  string `gorm:"column:sha256sum"`
	Next  string `gorm:"column:last_id"`
	Total int    `gorm:"column:total"`
}

func GetPrimaryKeysHash

func GetPrimaryKeysHash(ctx context.Context, req PaginateRequest, agentID uuid.UUID) (*PaginateResponse, error)

func (PaginateResponse) String added in v1.0.259

func (p PaginateResponse) String() string

type PushData

type PushData struct {
	AgentName                    string                               `json:"agent_name,omitempty"`
	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 GetMissingResourceIDs

func GetMissingResourceIDs(ctx context.Context, ids []string, paginateReq PaginateRequest) (*PushData, error)

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 UpstreamClient added in v1.0.192

type UpstreamClient struct {
	*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) 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

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

type UpstreamReconciler added in v1.0.265

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

UpstreamReconciler pushes missing resources from an agent to the upstream.

func NewUpstreamReconciler

func NewUpstreamReconciler(upstreamConf UpstreamConfig, pageSize int) *UpstreamReconciler

func (*UpstreamReconciler) Sync added in v1.0.265

func (t *UpstreamReconciler) Sync(ctx context.Context, table string) (int, error)

Sync compares all the resource of the given table against the upstream server and pushes any missing resources to the upstream.

func (*UpstreamReconciler) SyncAfter added in v1.0.265

func (t *UpstreamReconciler) SyncAfter(ctx context.Context, table string, after time.Duration) (int, error)

SyncAfter pushes all the records of the given table that were updated in the given duration

Jump to

Keyboard shortcuts

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