Documentation
¶
Overview ¶
Package pgstore implements the userstore.Store interface using PostgreSQL
Index ¶
- type PGDataStore
- func (s *PGDataStore) Close() error
- func (s *PGDataStore) DeleteTag(ctx context.Context, endpointID, key string) error
- func (s *PGDataStore) GetAgentByHostname(ctx context.Context, hostname string) (*model.Agent, error)
- func (s *PGDataStore) GetAgentByID(ctx context.Context, id string) (*model.Agent, error)
- func (s *PGDataStore) GetAllTags(ctx context.Context) ([]model.Tag, error)
- func (s *PGDataStore) GetContainerByID(ctx context.Context, id string) (*model.Container, error)
- func (s *PGDataStore) GetTags(ctx context.Context, endpointID string) (map[string]string, error)
- func (s *PGDataStore) InsertFullProcessPayload(ctx context.Context, payload *model.ProcessPayload) error
- func (s *PGDataStore) InsertProcessInfos(ctx context.Context, snapshotID int64, payload *model.ProcessPayload) error
- func (s *PGDataStore) InsertProcessSnapshot(ctx context.Context, snap *model.ProcessPayload) (int64, error)
- func (s *PGDataStore) ListAgents(ctx context.Context) ([]*model.Agent, error)
- func (s *PGDataStore) ListContainers(ctx context.Context) ([]*model.Container, error)
- func (s *PGDataStore) ListKeys(ctx context.Context) ([]string, error)
- func (s *PGDataStore) ListTags(ctx context.Context, endpointID string) (map[string]string, error)
- func (s *PGDataStore) ListValues(ctx context.Context, key string) ([]string, error)
- func (s *PGDataStore) QueryProcessInfos(ctx context.Context, filter *model.ProcessQueryFilter) ([]model.ProcessInfo, error)
- func (s *PGDataStore) SetTags(ctx context.Context, endpointID string, tags map[string]string) error
- func (s *PGDataStore) UpsertAgent(ctx context.Context, agent *model.Agent) error
- func (s *PGDataStore) UpsertContainer(ctx context.Context, c *model.Container) error
- func (s *PGDataStore) Write(ctx context.Context, batches []*model.ProcessPayload) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PGDataStore ¶
type PGDataStore struct {
// contains filtered or unexported fields
}
Package pgstore implements the userstore.Store interface using PostgreSQL PGDataStore is a struct that represents a PostgreSQL data store It contains a pointer to the sql.DB object for database operations
func NewPGDataStore ¶
func NewPGDataStore(db *sql.DB) *PGDataStore
New creates a new PGDataStore instance
func (*PGDataStore) Close ¶
func (s *PGDataStore) Close() error
Close closes the database connection It checks if the db is not nil before attempting to close it
func (*PGDataStore) DeleteTag ¶
func (s *PGDataStore) DeleteTag(ctx context.Context, endpointID, key string) error
DeleteTag removes a specific tag for a given endpoint ID.
func (*PGDataStore) GetAgentByHostname ¶
func (s *PGDataStore) GetAgentByHostname(ctx context.Context, hostname string) (*model.Agent, error)
GetAgentByHostname retrieves an agent by its hostname
func (*PGDataStore) GetAgentByID ¶
GetAgentByAgentID retrieves an agent by its agent_id This is used for the agent to check in with the server
func (*PGDataStore) GetAllTags ¶
func (*PGDataStore) GetContainerByID ¶
GetContainerByID retrieves a container by its container_id
func (*PGDataStore) InsertFullProcessPayload ¶
func (s *PGDataStore) InsertFullProcessPayload(ctx context.Context, payload *model.ProcessPayload) error
InsertFullProcessPayload inserts a complete process payload into the database,
func (*PGDataStore) InsertProcessInfos ¶
func (s *PGDataStore) InsertProcessInfos(ctx context.Context, snapshotID int64, payload *model.ProcessPayload) error
InsertProcessInfos inserts multiple process information records associated with a snapshot.
func (*PGDataStore) InsertProcessSnapshot ¶
func (s *PGDataStore) InsertProcessSnapshot(ctx context.Context, snap *model.ProcessPayload) (int64, error)
InsertProcessSnapshot inserts a new process snapshot into the database.
func (*PGDataStore) ListAgents ¶
ListAgents retrieves all agents from the database This is used for the web UI to display all agents and for the agent to check in with the server
func (*PGDataStore) ListContainers ¶
ListContainers retrieves all containers from the database This is used for the web UI to display all containers and for the agent to check in with the server
func (*PGDataStore) ListKeys ¶
func (s *PGDataStore) ListKeys(ctx context.Context) ([]string, error)
ListKeys returns all unique tag keys
func (*PGDataStore) ListValues ¶
ListValues returns all values for a given key
func (*PGDataStore) QueryProcessInfos ¶
func (s *PGDataStore) QueryProcessInfos(ctx context.Context, filter *model.ProcessQueryFilter) ([]model.ProcessInfo, error)
func (*PGDataStore) SetTags ¶
SetTags replaces all tags for a given endpoint ID with the provided tags.
func (*PGDataStore) UpsertAgent ¶
func (*PGDataStore) UpsertContainer ¶
UpsertContainer inserts or updates a container in the database This is used for the agent to check in with the server It also updates the last_seen field to the current time and the status field to "Running" if the container is running or "Stopped" if the container is stopped UpsertContainer inserts or updates a container in the database
func (*PGDataStore) Write ¶
func (s *PGDataStore) Write(ctx context.Context, batches []*model.ProcessPayload) error
Write fullfills the interface in BufferedDataStore