Documentation
¶
Index ¶
- Constants
- Variables
- func SendError(c *fiber.Ctx, status int, err interface{}) error
- func SendErrorWithType(c *fiber.Ctx, status int, err interface{}, errorType models.ErrorType) error
- func SendSuccess(c *fiber.Ctx, status int, data interface{}) error
- type ActiveQuery
- type MetaResponse
- type QueryTracker
- func (qt *QueryTracker) AddQuery(userID models.UserID, sourceID models.SourceID, teamID models.TeamID, ...) string
- func (qt *QueryTracker) CancelQuery(queryID string, userID models.UserID) bool
- func (qt *QueryTracker) Cleanup()
- func (qt *QueryTracker) GetUserQueries(userID models.UserID) []*ActiveQuery
- func (qt *QueryTracker) RemoveQuery(queryID string)
- type Response
- type Server
- type ServerOptions
- type SettingsByCategoryResponse
- type SystemSettingResponse
- type TestEmailRequest
- type TestWebhookRequest
- type TranslateRequest
- type TranslateResponse
- type UpdateSettingRequest
- type UserPreferencesResponse
- type ValidateRequest
- type ValidateResponse
Constants ¶
const ( // OpenAIRequestTimeout is the maximum time to wait for OpenAI to respond OpenAIRequestTimeout = 15 * time.Second // FieldValuesTimeout is the maximum time to wait for field values queries // This propagates to ClickHouse as max_execution_time via the context deadline FieldValuesTimeout = 15 * time.Second )
Added constant
Variables ¶
var ( // Note: Some errors might overlap with core definitions but are kept here // for mapping purposes within redirectToFrontend. ErrSessionNotFound = errors.New("session not found") ErrSessionExpired = errors.New("session expired") ErrUserNotFound = errors.New("user not found") ErrTeamNotFound = errors.New("team not found") ErrUserInactive = errors.New("user inactive") ErrOIDCProviderNotConfigured = errors.New("OIDC provider not configured") // This one might belong in auth/oidc.go ErrOIDCInvalidToken = errors.New("invalid OIDC token") ErrOIDCEmailNotVerified = errors.New("email not verified") )
Define Auth/OIDC specific errors used within handlers, especially for redirect mapping.
Functions ¶
func SendError ¶
SendError is a helper function to easily send a JSON error response with the given HTTP status code and error message. It uses the GeneralErrorType by default.
func SendErrorWithType ¶
SendErrorWithType is a helper function to easily send a JSON error response with the given HTTP status code, error message, and a specific application error type.
Types ¶
type ActiveQuery ¶ added in v0.4.0
type ActiveQuery struct {
ID string
UserID models.UserID
SourceID models.SourceID
TeamID models.TeamID
StartTime time.Time
SQL string
Cancel context.CancelFunc
}
ActiveQuery represents an active query with its context for cancellation
type MetaResponse ¶ added in v0.2.2
type MetaResponse struct {
Version string `json:"version"`
HTTPServerTimeout string `json:"http_server_timeout"`
OIDCIssuer string `json:"oidc_issuer,omitempty"`
CLIClientID string `json:"cli_client_id,omitempty"`
MaxQueryLimit int `json:"max_query_limit"`
}
MetaResponse represents the server metadata response
type QueryTracker ¶ added in v0.4.0
type QueryTracker struct {
// contains filtered or unexported fields
}
QueryTracker manages active queries for cancellation support
func (*QueryTracker) AddQuery ¶ added in v0.4.0
func (qt *QueryTracker) AddQuery(userID models.UserID, sourceID models.SourceID, teamID models.TeamID, sql string, cancel context.CancelFunc) string
AddQuery adds a new active query to the tracker
func (*QueryTracker) CancelQuery ¶ added in v0.4.0
func (qt *QueryTracker) CancelQuery(queryID string, userID models.UserID) bool
CancelQuery cancels a query if it exists and belongs to the user
func (*QueryTracker) Cleanup ¶ added in v0.4.0
func (qt *QueryTracker) Cleanup()
Cleanup removes queries that have been running for too long (over 1 hour)
func (*QueryTracker) GetUserQueries ¶ added in v0.4.0
func (qt *QueryTracker) GetUserQueries(userID models.UserID) []*ActiveQuery
GetUserQueries returns all active queries for a user
func (*QueryTracker) RemoveQuery ¶ added in v0.4.0
func (qt *QueryTracker) RemoveQuery(queryID string)
RemoveQuery removes a query from the tracker
type Response ¶
type Response struct {
Status string `json:"status"` // "success" or "error"
Data interface{} `json:"data,omitempty"`
Message string `json:"message,omitempty"`
ErrorType string `json:"error_type,omitempty"` // Application-specific error type code.
}
Response defines the standard JSON structure for API responses.
func NewErrorResponse ¶
NewErrorResponse creates a standard error response structure. It accepts various error types and maps them to a consistent JSON format.
func NewSuccessResponse ¶
func NewSuccessResponse(data interface{}) Response
NewSuccessResponse creates a standard success response structure.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the core HTTP server, encapsulating the Fiber app instance and necessary dependencies like database connections and configuration.
func New ¶
func New(opts ServerOptions) *Server
New creates, configures, and returns a new Server instance. It initializes the Fiber application, sets up middleware, injects dependencies, and registers all application routes.
type ServerOptions ¶
type ServerOptions struct {
Config *config.Config
SQLite *sqlite.DB
ClickHouse *clickhouse.Manager
AlertsManager *alerts.Manager // Alerts manager for manual resolution and notifications.
OIDCProvider *auth.OIDCProvider // OIDC provider for authentication flows.
FS http.FileSystem // Filesystem for serving static assets (frontend).
Logger *slog.Logger
BuildInfo string
Version string
}
ServerOptions holds the dependencies required to create a new Server instance. This structure reflects the refactored approach using direct dependencies instead of services.
type SettingsByCategoryResponse ¶ added in v0.6.0
type SettingsByCategoryResponse struct {
Category string `json:"category"`
Settings []SystemSettingResponse `json:"settings"`
}
SettingsByCategoryResponse groups settings by category.
type SystemSettingResponse ¶ added in v0.6.0
type SystemSettingResponse struct {
Key string `json:"key"`
Value string `json:"value"`
ValueType string `json:"value_type"`
Category string `json:"category"`
Description string `json:"description,omitempty"`
IsSensitive bool `json:"is_sensitive"`
MaskedValue string `json:"masked_value,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
SystemSettingResponse represents a setting in API responses.
type TestEmailRequest ¶ added in v1.2.0
type TestEmailRequest struct {
RecipientEmail string `json:"recipient_email"`
}
TestEmailRequest represents a request to send a test email.
type TestWebhookRequest ¶ added in v1.2.0
type TestWebhookRequest struct {
WebhookURL string `json:"webhook_url"`
}
TestWebhookRequest represents a request to send a test webhook.
type TranslateRequest ¶ added in v1.0.0
type TranslateRequest struct {
Query string `json:"query"`
StartTime string `json:"start_time"` // Optional. Format: "2006-01-02 15:04:05" - required for full_sql
EndTime string `json:"end_time"` // Optional. Format: "2006-01-02 15:04:05" - required for full_sql
Timezone string `json:"timezone"` // Optional. e.g., "UTC", "Asia/Kolkata" - required for full_sql
Limit int `json:"limit"` // Optional. e.g., 100 - defaults to 100
}
TranslateRequest represents the request body for LogchefQL translation
type TranslateResponse ¶ added in v1.0.0
type TranslateResponse struct {
SQL string `json:"sql"` // WHERE clause conditions only
FullSQL string `json:"full_sql,omitempty"` // Complete executable SQL (when time params provided)
Valid bool `json:"valid"`
Error *logchefql.ParseError `json:"error,omitempty"`
Conditions []logchefql.FilterCondition `json:"conditions"`
FieldsUsed []string `json:"fields_used"`
}
TranslateResponse represents the response for LogchefQL translation
type UpdateSettingRequest ¶ added in v0.6.0
type UpdateSettingRequest struct {
Value string `json:"value"`
ValueType string `json:"value_type"`
Category string `json:"category"`
Description string `json:"description"`
IsSensitive bool `json:"is_sensitive"`
}
UpdateSettingRequest represents a request to update a setting.
type UserPreferencesResponse ¶ added in v1.3.0
type UserPreferencesResponse struct {
Preferences models.UserPreferences `json:"preferences"`
IsDefault bool `json:"is_default"`
}
UserPreferencesResponse represents user preferences in API responses.
type ValidateRequest ¶ added in v1.0.0
type ValidateRequest struct {
Query string `json:"query"`
}
ValidateRequest represents the request body for LogchefQL validation
type ValidateResponse ¶ added in v1.0.0
type ValidateResponse struct {
Valid bool `json:"valid"`
Error *logchefql.ParseError `json:"error,omitempty"`
}
ValidateResponse represents the response for LogchefQL validation