web

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivateSubscription

func ActivateSubscription(c *fiber.Ctx) error

ActivateSubscription activates a subscription by ID.

func CancelRun added in v0.5.3

func CancelRun(c *fiber.Ctx) error

CancelRun aborts an in-progress run. With ?force=true the run_history row is marked cancelled and the registry slot is freed immediately; the already-running goroutine continues until it observes ctx.Done() (or completes its in-flight HTTP/sleep) and is detached from the registry so a new run can be triggered. Without force the context is cancelled and the goroutine is allowed to finalise the row itself on the way out.

Returns 200 with `{status:"cancelled"|"cancelling"}` on success, 404 when no run is active for the subscription.

func CreateFiberApp

func CreateFiberApp(myLibrary *library.Library, registry *RunRegistry, logCapture *LogCapture, scheduler *Scheduler) *fiber.App

func CreatePublication

func CreatePublication(c *fiber.Ctx) error

CreatePublication creates a new empty published view for a data type.

func CreateSubscription

func CreateSubscription(c *fiber.Ctx) error

CreateSubscription creates a new subscription from JSON body.

func DeactivateSubscription

func DeactivateSubscription(c *fiber.Ctx) error

DeactivateSubscription deactivates a subscription by ID.

func DeletePublication

func DeletePublication(c *fiber.Ctx) error

DeletePublication deletes a published view and its database view.

func DeleteSubscription

func DeleteSubscription(c *fiber.Ctx) error

DeleteSubscription deletes a subscription by ID.

func DownloadRunLog added in v0.5.3

func DownloadRunLog(c *fiber.Ctx) error

DownloadRunLog returns the captured log text for a run as an attachment. The body is raw newline-delimited JSON (the underlying zerolog format). Returns 404 when the subscription is unknown, 204 when no log was captured or it has been swept by the 30-day retention.

func ExecuteSQL

func ExecuteSQL(c *fiber.Ctx) error

ExecuteSQL runs a user-provided SQL query in a read-only transaction.

func ExportSQL

func ExportSQL(c *fiber.Ctx) error

ExportSQL runs a SQL query and exports results as CSV or Parquet.

func GetAvailablePublicationTypes

func GetAvailablePublicationTypes(c *fiber.Ctx) error

GetAvailablePublicationTypes returns data types that can have new published views.

func GetProviders

func GetProviders(c *fiber.Ctx) error

GetProviders returns a map of all registered providers keyed by provider key.

func GetPublicConfig added in v0.4.0

func GetPublicConfig(c *fiber.Ctx) error

GetPublicConfig returns the runtime config payload consumed by the SPA.

func GetPublication

func GetPublication(c *fiber.Ctx) error

GetPublication returns a single published view with enriched source metadata.

func GetPublicationCandidates

func GetPublicationCandidates(c *fiber.Ctx) error

GetPublicationCandidates returns subscription tables eligible as sources.

func GetPublications

func GetPublications(c *fiber.Ctx) error

GetPublications returns all published views as summaries.

func GetQualityIssues

func GetQualityIssues(c *fiber.Ctx) error

GetQualityIssues returns paginated data quality issues with optional filters.

func GetQualitySummary

func GetQualitySummary(c *fiber.Ctx) error

GetQualitySummary returns counts of issues grouped by check_name, severity, and data_type.

func GetRunHistory

func GetRunHistory(c *fiber.Ctx) error

GetRunHistory returns paginated run history for a subscription.

func GetRunLog added in v0.4.3

func GetRunLog(c *fiber.Ctx) error

GetRunLog returns a paged slice of the captured log text for a specific run_history row. The response shape is:

{
  "lines":      ["..."],   // chronological order
  "total":      <int>,     // total line count across the full log
  "start_line": <int>,     // 1-indexed lineno of lines[0] (0 when empty)
  "limit":      <int>      // applied page size
}

Query parameters:

  • limit -- page size (default 1000, capped at 5000)
  • before -- upper-bound line cursor (exclusive) for "load earlier" paging. Omit or set to 0 to fetch the tail (newest lines).

`lines` is empty when no log was ever captured or the 30-day retention has cleared it. To download the full log unpaged, use the /log/download endpoint.

func GetRunSparkline

func GetRunSparkline(c *fiber.Ctx) error

GetRunSparkline returns daily aggregated observation counts for sparkline display.

func GetSubscription

func GetSubscription(c *fiber.Ctx) error

GetSubscription returns a single subscription by ID prefix.

func GetSubscriptionData

func GetSubscriptionData(c *fiber.Ctx) error

GetSubscriptionData queries dynamic data from a subscription's data table.

func GetSubscriptions

func GetSubscriptions(c *fiber.Ctx) error

GetSubscriptions returns all subscriptions.

func NewAuthMiddleware

func NewAuthMiddleware() fiber.Handler

NewAuthMiddleware returns a Fiber handler that validates RS256 JWTs against the configured OIDC issuer. Works with any provider (Auth0, Zitadel, etc.) that publishes a JWKS and issues RS256-signed tokens.

Required config keys:

auth.issuer    — full issuer URL exactly as it appears in the token's iss claim
auth.jwks_url  — full JWKS URL
auth.audience  — expected audience claim

When auth.issuer is empty, it returns a pass-through middleware for dev mode.

func QualityCheckEvents

func QualityCheckEvents(c *fiber.Ctx) error

QualityCheckEvents streams SSE for an active quality check.

func RunEvents

func RunEvents(c *fiber.Ctx) error

RunEvents streams Server-Sent Events for an active subscription run.

func RunStatus added in v0.4.3

func RunStatus(c *fiber.Ctx) error

RunStatus reports whether a run is currently active for a subscription. Used by the UI to auto-attach SSE on page load if a run started elsewhere (e.g. by the scheduler).

func RunSubscription added in v0.4.3

func RunSubscription(ctx context.Context, lib *library.Library, sub *library.Subscription, opts RunOptions)

RunSubscription executes a fetch for the subscription, persists observations, saves run history, runs post-fetch hooks, publishes SSE events (if a run is attached), and pings healthchecks at start and finish.

The caller must reserve a registry slot via TryReserve and pass the resulting activeRun in opts.Run. RunSubscription owns the run lifecycle thereafter and will call run.finish() before returning.

func SetupRoutes

func SetupRoutes(app *fiber.App)

func SetupSPA

func SetupSPA(app *fiber.App)

SetupSPA configures the Fiber app to serve the embedded Vue SPA. Static files are served from the embedded ui/dist directory. Non-matching routes fall back to index.html for SPA history-mode routing via the filesystem middleware's NotFoundFile option.

func TriggerQualityCheck

func TriggerQualityCheck(c *fiber.Ctx) error

TriggerQualityCheck starts a data quality audit in the background.

func TriggerRun

func TriggerRun(c *fiber.Ctx) error

TriggerRun starts an on-demand run for a subscription. Accepts optional query param: ?lookback=30d (e.g. "7d", "30d", "365d"). Default: 14d.

func UpdatePublication

func UpdatePublication(c *fiber.Ctx) error

UpdatePublication updates the sources of a published view.

func UpdateSubscription

func UpdateSubscription(c *fiber.Ctx) error

UpdateSubscription updates fields on an existing subscription.

Types

type AvailableType

type AvailableType struct {
	DataTypeKey string `json:"data_type_key"`
	ViewName    string `json:"view_name"`
}

AvailableType is a data type that can have a new published view created.

type CandidateSource

type CandidateSource struct {
	TableName        string `json:"table_name"`
	SubscriptionID   string `json:"subscription_id"`
	SubscriptionName string `json:"subscription_name"`
	Provider         string `json:"provider"`
	Dataset          string `json:"dataset"`
}

CandidateSource is a subscription table eligible to be added as a source.

type CreatePublicationRequest

type CreatePublicationRequest struct {
	DataTypeKey string `json:"data_type_key"`
}

CreatePublicationRequest is the JSON body for creating a new published view.

type CreateSubscriptionRequest

type CreateSubscriptionRequest struct {
	Provider          string            `json:"provider"`
	Dataset           string            `json:"dataset"`
	Config            map[string]string `json:"config"`
	Schedule          string            `json:"schedule"`
	DataTypes         []string          `json:"data_types"`
	HealthCheckID     string            `json:"health_check_id"`
	CreateHealthcheck bool              `json:"create_healthcheck"`
}

CreateSubscriptionRequest is the JSON body for creating a new subscription.

type EnrichedPublishedView

type EnrichedPublishedView struct {
	ID          uuid.UUID        `json:"id"`
	ViewName    string           `json:"view_name"`
	DataTypeKey string           `json:"data_type_key"`
	Sources     []EnrichedSource `json:"sources"`
	Overlaps    []string         `json:"overlaps,omitempty"`
}

EnrichedPublishedView is a PublishedView with enriched sources and overlap warnings.

type EnrichedSource

type EnrichedSource struct {
	TableName        string  `json:"table_name"`
	SubscriptionID   string  `json:"subscription_id"`
	FromDate         *string `json:"from_date"`
	UntilDate        *string `json:"until_date"`
	SubscriptionName string  `json:"subscription_name"`
	Provider         string  `json:"provider"`
	Dataset          string  `json:"dataset"`
}

EnrichedSource is a ViewSource augmented with subscription metadata for the UI.

type HttpError

type HttpError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type LogCapture added in v0.4.3

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

LogCapture is an io.Writer that intercepts zerolog's JSON output, picks out events tagged with a SubscriptionID matching an active run, and:

  1. publishes a "log" SSE event to the run's event channel so connected clients see logs streaming in real time,
  2. appends the line to a per-run buffer that the run pipeline drains and persists alongside the run history record.

The writer also forwards every line untouched to a passthrough writer (typically the existing zerolog ConsoleWriter) so dev/console output is unchanged.

The per-run buffer is intentionally unbounded: the captured log is preserved in full for diagnostic value, with retention enforced at the database layer via SweepRunLogs (30 days by default).

func NewLogCapture added in v0.4.3

func NewLogCapture(registry *RunRegistry) *LogCapture

NewLogCapture creates a capture sink bound to the given registry.

func (*LogCapture) Drain added in v0.4.3

func (lc *LogCapture) Drain(subID string) string

Drain returns the captured log buffer for the subscription and clears it. Call once when a run completes.

func (*LogCapture) Snapshot added in v0.5.2

func (lc *LogCapture) Snapshot(subID string) string

Snapshot returns a copy of the captured log buffer for the subscription without clearing it. Use this for periodic in-flight flushes to the run_history.log column so partial logs survive an abrupt process exit; pair it with a final Drain at run-end.

func (*LogCapture) Write added in v0.4.3

func (lc *LogCapture) Write(p []byte) (int, error)

Write implements io.Writer. Each Write call is one zerolog event in JSON.

type ProgressThrottle added in v0.5.0

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

ProgressThrottle invokes emit at most once per interval. The first Tick fires immediately; later Ticks within the interval are dropped but the most recent count is remembered so Flush can emit it later. Not safe for concurrent Ticks.

func NewProgressThrottle added in v0.5.0

func NewProgressThrottle(interval time.Duration, emit func(int)) *ProgressThrottle

NewProgressThrottle returns a throttle that calls emit at most once per interval.

func (*ProgressThrottle) Flush added in v0.5.0

func (p *ProgressThrottle) Flush()

Flush emits the most recent pending count even if the interval has not elapsed. Safe to call when nothing is pending; in that case it is a no-op.

func (*ProgressThrottle) Tick added in v0.5.0

func (p *ProgressThrottle) Tick(now time.Time, count int)

Tick records the latest count. If the interval has elapsed since the last emit (or this is the first tick), emit fires immediately.

type ProviderResponse

type ProviderResponse struct {
	Name              string                             `json:"name"`
	Description       string                             `json:"description"`
	ConfigDescription map[string]string                  `json:"config_description"`
	Datasets          map[string]providerDatasetResponse `json:"datasets"`
}

ProviderResponse describes a single provider and its datasets.

type PublicConfig added in v0.4.0

type PublicConfig struct {
	AuthIssuer   string `json:"auth_issuer"`
	AuthClientID string `json:"auth_client_id"`
	AuthAudience string `json:"auth_audience"`
	Version      string `json:"version"`
	Commit       string `json:"commit"`
	BuildDate    string `json:"build_date"`
}

PublicConfig is the runtime config the embedded SPA fetches at boot to wire its OIDC client. Only values safe to expose to a browser belong here — never secrets.

type PublishedViewSummary

type PublishedViewSummary struct {
	ID          uuid.UUID `json:"id"`
	ViewName    string    `json:"view_name"`
	DataTypeKey string    `json:"data_type_key"`
	SourceCount int       `json:"source_count"`
}

PublishedViewSummary is the list response item.

type QualityIssue

type QualityIssue struct {
	ID             uuid.UUID  `json:"id"`
	CheckName      string     `json:"check_name"`
	Severity       string     `json:"severity"`
	DataType       string     `json:"data_type"`
	Ticker         *string    `json:"ticker"`
	CompositeFIGI  *string    `json:"composite_figi"`
	Dimension      *string    `json:"dimension"`
	EventDate      *time.Time `json:"event_date"`
	Field          *string    `json:"field"`
	Message        string     `json:"message"`
	Expected       *string    `json:"expected"`
	Actual         *string    `json:"actual"`
	SubscriptionID *uuid.UUID `json:"subscription_id"`
	RunID          *uuid.UUID `json:"run_id"`
	DetectedAt     time.Time  `json:"detected_at"`
}

QualityIssue represents a single row from data_quality_issues.

type QualityIssuesResponse

type QualityIssuesResponse struct {
	Issues []QualityIssue `json:"issues"`
	Total  int            `json:"total"`
	Limit  int            `json:"limit"`
	Offset int            `json:"offset"`
}

QualityIssuesResponse is the paginated response for GetQualityIssues.

type QualitySummaryRow

type QualitySummaryRow struct {
	CheckName string `json:"check_name"`
	Severity  string `json:"severity"`
	DataType  string `json:"data_type"`
	Count     int    `json:"count"`
}

QualitySummaryRow represents a single group in the summary query.

type RunOptions added in v0.4.3

type RunOptions struct {
	// Run is the registry-managed activeRun. Required when callers want SSE
	// streaming or auto-attach support; pre-reserve via registry.TryReserve.
	Run *activeRun
	// Lookback overrides the default fetch window when non-zero.
	Lookback time.Duration
	// Source labels the run for logs / healthcheck bodies.
	Source RunSource
	// LogCapture, when set, drains the per-run log buffer so it can be
	// persisted alongside run history. Set by the serve command at startup.
	LogCapture *LogCapture
}

RunOptions configures a subscription run.

type RunRegistry

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

RunRegistry manages active subscription runs (scheduled and on-demand), keyed by subscription ID string.

func NewRunRegistry

func NewRunRegistry() *RunRegistry

NewRunRegistry creates an empty registry.

func (*RunRegistry) Delete

func (r *RunRegistry) Delete(subscriptionID string)

Delete removes an active run entry unconditionally.

func (*RunRegistry) DeleteIf added in v0.5.3

func (r *RunRegistry) DeleteIf(subscriptionID string, run *activeRun)

DeleteIf removes the entry only if the current value matches run. Used by finish() so a force-cancel that already replaced or freed the slot is not double-released by the eventually-exiting goroutine.

func (*RunRegistry) IsActive added in v0.4.3

func (r *RunRegistry) IsActive(subscriptionID string) bool

IsActive reports whether a run is currently in progress for the subscription.

func (*RunRegistry) Load

func (r *RunRegistry) Load(subscriptionID string) (*activeRun, bool)

Load retrieves an active run by subscription ID.

func (*RunRegistry) TryReserve added in v0.4.3

func (r *RunRegistry) TryReserve(subscriptionID string) (*activeRun, bool)

TryReserve atomically claims a slot for a subscription run. Returns the activeRun and true on success, or (nil, false) if a run is already in progress for the subscription.

type RunSource added in v0.4.3

type RunSource string

RunSource labels the trigger origin of a subscription run for logs and healthcheck ping bodies.

const (
	RunSourceScheduled RunSource = "scheduled"
	RunSourceManual    RunSource = "manual"
)

type SQLRequest

type SQLRequest struct {
	Query string `json:"query"`
}

SQLRequest is the JSON body for SQL execution endpoints.

type Scheduler added in v0.5.0

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

Scheduler wraps a gocron.Scheduler with per-subscription job tracking so the web handlers can add, remove, and replace jobs as subscriptions are created, edited, activated, or deactivated.

func NewScheduler added in v0.5.0

func NewScheduler(inner gocron.Scheduler, runner SubscriptionRunner) *Scheduler

NewScheduler wraps the given gocron.Scheduler. The runner is called on every cron fire with the subscription id.

func (*Scheduler) Schedule added in v0.5.0

func (s *Scheduler) Schedule(sub *library.Subscription) error

Schedule registers (or replaces) the cron job for sub. No-op when sub or sub.Schedule is empty.

func (*Scheduler) Unschedule added in v0.5.0

func (s *Scheduler) Unschedule(subID uuid.UUID) error

Unschedule removes the cron job registered for the subscription, if any.

type SubscriptionRunner added in v0.5.0

type SubscriptionRunner func(subID uuid.UUID)

SubscriptionRunner is invoked by Scheduler when a subscription's cron fires. It receives only the subscription id so the runner can load the current subscription state from the library, ensuring edits made after scheduling (config, schedule, etc.) are reflected on the next run.

type UpdatePublicationRequest

type UpdatePublicationRequest struct {
	Sources []library.ViewSource `json:"sources"`
}

UpdatePublicationRequest is the JSON body for updating published view sources.

type UpdateSubscriptionRequest

type UpdateSubscriptionRequest struct {
	Name          *string            `json:"name"`
	Schedule      *string            `json:"schedule"`
	Config        *map[string]string `json:"config"`
	HealthCheckID *string            `json:"health_check_id"`
	Active        *bool              `json:"active"`
}

UpdateSubscriptionRequest is the JSON body for updating an existing subscription.

Jump to

Keyboard shortcuts

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