msgproc

package
v0.12.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package msgproc provides a service for processing of incoming events.

Index

Constants

View Source
const (
	HintExplain = "Consider using `explain` command for DML statements. See `help` for details."
	HintExec    = "Consider using `exec` command for DDL statements. See `help` for details."
)

Hint messages.

View Source
const (
	PasswordLength     = 16
	PasswordMinDigits  = 4
	PasswordMinSymbols = 0
)

Constants for autogenerated passwords.

View Source
const (
	CommandExplain   = "explain"
	CommandExec      = "exec"
	CommandReset     = "reset"
	CommandHelp      = "help"
	CommandHypo      = "hypo"
	CommandActivity  = "activity"
	CommandTerminate = "terminate"
	CommandPlan      = "plan"

	CommandPsqlD   = `\d`
	CommandPsqlDP  = `\d+`
	CommandPsqlDT  = `\dt`
	CommandPsqlDTP = `\dt+`
	CommandPsqlDI  = `\di`
	CommandPsqlDIP = `\di+`
	CommandPsqlL   = `\l`
	CommandPsqlLP  = `\l+`
	CommandPsqlDV  = `\dv`
	CommandPsqlDVP = `\dv+`
	CommandPsqlDM  = `\dm`
	CommandPsqlDMP = `\dm+`
)

Constants declare supported commands.

View Source
const HelpMessage = "\n• `explain` — analyze your query (SELECT, INSERT, DELETE, UPDATE or WITH) and generate recommendations\n" +
	"• `plan` — analyze your query (SELECT, INSERT, DELETE, UPDATE or WITH) without execution\n" +
	"• `exec` — execute any query (for example, CREATE INDEX)\n" +
	"• `activity` — show currently running sessions in Postgres (states: `active`, `idle in transaction`, `disabled`)\n" +
	"• `terminate [pid]` — terminate Postgres backend that has the specified PID.\n" +
	"• `reset` — revert the database to the initial state (usually takes less than a minute, :warning: all changes will be lost)\n" +
	"• `\\d`, `\\d+`, `\\dt`, `\\dt+`, `\\di`, `\\di+`, `\\l`, `\\l+`, `\\dv`, `\\dv+`, `\\dm`, `\\dm+` — psql meta information commands\n" +
	"• `hypo` — create hypothetical indexes using the HypoPG extension\n" +
	"• `help` — this message\n\n" +
	"• Sessions are fully independent. Feel free to do anything.\n" +
	"• The session will be destroyed after the certain amount of time ('idle timeout') of inactivity.\n" +
	"• EXPLAIN plans here are expected to be identical to production plans.\n" +
	"• The actual timing values may differ from production because actual caches in DB Lab are smaller. " +
	"However, the number of bytes and pages/buffers in plans match the production database.\n"

HelpMessage defines available commands provided with the help message.

View Source
const MsgSessionStarting = "Starting a new session..."

MsgSessionStarting provides a message for a session start.

View Source
const QueryPreviewSize = 400

QueryPreviewSize defines a max preview size of query in message.

View Source
const SeparatorEllipsis = "\n[...SKIP...]\n"

SeparatorEllipsis provides a separator for cut messages.

Variables

This section is empty.

Functions

func InitConn

func InitConn(ctx context.Context, dblabClone models.Clone) (*pgxpool.Pool, *pgx.Conn, error)

InitConn initializes a new connection to clone.

Types

type ProcessingConfig

type ProcessingConfig struct {
	App      config.App
	Platform config.Platform
	DBLab    config.DBLabParams
	EntOpts  definition.EnterpriseOptions
	Project  string
}

ProcessingConfig declares a configuration of Processing Service.

type ProcessingService

type ProcessingService struct {
	DBLab       *dblabapi.Client
	UserManager *usermanager.UserManager
	// contains filtered or unexported fields
}

func NewProcessingService

func NewProcessingService(messengerSvc connection.Messenger, msgValidator connection.MessageValidator, dblab *dblabapi.Client,
	userSvc *usermanager.UserManager, platform *platform.Client, cfg ProcessingConfig,
	featurePack *features.Pack) *ProcessingService

NewProcessingService creates a new processing service.

func (*ProcessingService) CheckIdleSessions

func (s *ProcessingService) CheckIdleSessions(ctx context.Context)

CheckIdleSessions checks user idleness sessions and notifies about their finishing.

func (*ProcessingService) ProcessAppMentionEvent

func (s *ProcessingService) ProcessAppMentionEvent(incomingMessage models.IncomingMessage)

ProcessAppMentionEvent replies to an application mention event.

func (*ProcessingService) ProcessMessageEvent

func (s *ProcessingService) ProcessMessageEvent(ctx context.Context, incomingMessage models.IncomingMessage)

ProcessMessageEvent replies to a message.

func (*ProcessingService) RestoreSessions

func (s *ProcessingService) RestoreSessions(ctx context.Context) error

RestoreSessions checks sessions after restart and establishes DB connection.

func (*ProcessingService) Users

Users returns all tracked users with session data.

Jump to

Keyboard shortcuts

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