Documentation
¶
Overview ¶
Package mongo provides a MongoDB implementation of the store.Store interface.
MongoDB is a document database that stores data as flexible BSON documents. This implementation uses the official MongoDB Go driver v2 and maps each domain entity type to a dedicated collection with appropriate indexes. It is suitable for production deployments requiring horizontal scalability and flexible schema evolution.
Index ¶
- type Config
- type Store
- func (s *Store) Close() error
- func (s *Store) CountByTenant(ctx context.Context, tenantID string) (int, error)
- func (s *Store) CountDomainsByTenant(ctx context.Context, tenantID string) (int, error)
- func (s *Store) CountSecretsByTenant(ctx context.Context, tenantID string) (int, error)
- func (s *Store) CountTenants(ctx context.Context) (int, error)
- func (s *Store) CountTenantsByStatus(ctx context.Context, status admin.TenantStatus) (int, error)
- func (s *Store) Delete(ctx context.Context, tenantID string, instanceID id.ID) error
- func (s *Store) DeleteCertificate(ctx context.Context, tenantID string, certID id.ID) error
- func (s *Store) DeleteCheck(ctx context.Context, tenantID string, checkID id.ID) error
- func (s *Store) DeleteDomain(ctx context.Context, tenantID string, domainID id.ID) error
- func (s *Store) DeleteRoute(ctx context.Context, tenantID string, routeID id.ID) error
- func (s *Store) DeleteSecret(ctx context.Context, tenantID string, instanceID id.ID, key string) error
- func (s *Store) DeleteTenant(ctx context.Context, tenantID string) error
- func (s *Store) GetByID(ctx context.Context, tenantID string, instanceID id.ID) (*instance.Instance, error)
- func (s *Store) GetBySlug(ctx context.Context, tenantID string, slug string) (*instance.Instance, error)
- func (s *Store) GetCertificate(ctx context.Context, tenantID string, certID id.ID) (*network.Certificate, error)
- func (s *Store) GetCheck(ctx context.Context, tenantID string, checkID id.ID) (*health.HealthCheck, error)
- func (s *Store) GetDeployment(ctx context.Context, tenantID string, deployID id.ID) (*deploy.Deployment, error)
- func (s *Store) GetDomain(ctx context.Context, tenantID string, domainID id.ID) (*network.Domain, error)
- func (s *Store) GetDomainByHostname(ctx context.Context, hostname string) (*network.Domain, error)
- func (s *Store) GetLatestResourceSnapshot(ctx context.Context, tenantID string, instanceID id.ID) (*telemetry.ResourceSnapshot, error)
- func (s *Store) GetLatestResult(ctx context.Context, tenantID string, checkID id.ID) (*health.HealthResult, error)
- func (s *Store) GetRelease(ctx context.Context, tenantID string, releaseID id.ID) (*deploy.Release, error)
- func (s *Store) GetRoute(ctx context.Context, tenantID string, routeID id.ID) (*network.Route, error)
- func (s *Store) GetSecretByKey(ctx context.Context, tenantID string, instanceID id.ID, key string) (*secrets.Secret, error)
- func (s *Store) GetTenant(ctx context.Context, tenantID string) (*admin.Tenant, error)
- func (s *Store) GetTenantBySlug(ctx context.Context, slug string) (*admin.Tenant, error)
- func (s *Store) Insert(ctx context.Context, inst *instance.Instance) error
- func (s *Store) InsertAuditEntry(ctx context.Context, entry *admin.AuditEntry) error
- func (s *Store) InsertCertificate(ctx context.Context, cert *network.Certificate) error
- func (s *Store) InsertCheck(ctx context.Context, check *health.HealthCheck) error
- func (s *Store) InsertDeployment(ctx context.Context, d *deploy.Deployment) error
- func (s *Store) InsertDomain(ctx context.Context, domain *network.Domain) error
- func (s *Store) InsertLogs(ctx context.Context, logs []telemetry.LogEntry) error
- func (s *Store) InsertMetrics(ctx context.Context, metrics []telemetry.Metric) error
- func (s *Store) InsertRelease(ctx context.Context, r *deploy.Release) error
- func (s *Store) InsertResourceSnapshot(ctx context.Context, snap *telemetry.ResourceSnapshot) error
- func (s *Store) InsertResult(ctx context.Context, result *health.HealthResult) error
- func (s *Store) InsertRoute(ctx context.Context, route *network.Route) error
- func (s *Store) InsertSecret(ctx context.Context, secret *secrets.Secret) error
- func (s *Store) InsertTenant(ctx context.Context, tenant *admin.Tenant) error
- func (s *Store) InsertTraces(ctx context.Context, traces []telemetry.Trace) error
- func (s *Store) List(ctx context.Context, tenantID string, opts instance.ListOptions) (*instance.ListResult, error)
- func (s *Store) ListCertificates(ctx context.Context, tenantID string, instanceID id.ID) ([]network.Certificate, error)
- func (s *Store) ListChecks(ctx context.Context, tenantID string, instanceID id.ID) ([]health.HealthCheck, error)
- func (s *Store) ListDeployments(ctx context.Context, tenantID string, instanceID id.ID, ...) (*deploy.DeployListResult, error)
- func (s *Store) ListDomains(ctx context.Context, tenantID string, instanceID id.ID) ([]network.Domain, error)
- func (s *Store) ListReleases(ctx context.Context, tenantID string, instanceID id.ID, ...) (*deploy.ReleaseListResult, error)
- func (s *Store) ListResourceSnapshots(ctx context.Context, tenantID string, instanceID id.ID, ...) ([]telemetry.ResourceSnapshot, error)
- func (s *Store) ListResults(ctx context.Context, tenantID string, checkID id.ID, ...) ([]health.HealthResult, error)
- func (s *Store) ListRoutes(ctx context.Context, tenantID string, instanceID id.ID) ([]network.Route, error)
- func (s *Store) ListSecrets(ctx context.Context, tenantID string, instanceID id.ID) ([]secrets.Secret, error)
- func (s *Store) ListTenants(ctx context.Context, opts admin.ListTenantsOptions) (*admin.TenantListResult, error)
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) NextReleaseVersion(ctx context.Context, tenantID string, instanceID id.ID) (int, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) QueryAuditLog(ctx context.Context, opts admin.AuditQuery) (*admin.AuditResult, error)
- func (s *Store) QueryLogs(ctx context.Context, q telemetry.LogQuery) ([]telemetry.LogEntry, error)
- func (s *Store) QueryMetrics(ctx context.Context, q telemetry.MetricQuery) ([]telemetry.Metric, error)
- func (s *Store) QueryTraces(ctx context.Context, q telemetry.TraceQuery) ([]telemetry.Trace, error)
- func (s *Store) Update(ctx context.Context, inst *instance.Instance) error
- func (s *Store) UpdateCertificate(ctx context.Context, cert *network.Certificate) error
- func (s *Store) UpdateCheck(ctx context.Context, check *health.HealthCheck) error
- func (s *Store) UpdateDeployment(ctx context.Context, d *deploy.Deployment) error
- func (s *Store) UpdateDomain(ctx context.Context, domain *network.Domain) error
- func (s *Store) UpdateRoute(ctx context.Context, route *network.Route) error
- func (s *Store) UpdateSecret(ctx context.Context, secret *secrets.Secret) error
- func (s *Store) UpdateTenant(ctx context.Context, tenant *admin.Tenant) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
URI string `env:"CP_MONGO_URI" json:"uri"`
Database string `default:"ctrlplane" env:"CP_MONGO_DATABASE" json:"database"`
MaxPoolSize uint64 `default:"100" env:"CP_MONGO_MAX_POOL_SIZE" json:"max_pool_size"`
MinPoolSize uint64 `default:"10" env:"CP_MONGO_MIN_POOL_SIZE" json:"min_pool_size"`
Timeout time.Duration `default:"10s" env:"CP_MONGO_TIMEOUT" json:"timeout"`
}
Config holds the configuration for the MongoDB store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a MongoDB-backed implementation of store.Store.
func (*Store) CountByTenant ¶
CountByTenant returns the total number of instances for a tenant.
func (*Store) CountDomainsByTenant ¶
CountDomainsByTenant returns the number of domains for a tenant.
func (*Store) CountSecretsByTenant ¶
CountSecretsByTenant returns the number of secrets for a tenant.
func (*Store) CountTenants ¶
CountTenants returns the total number of tenants.
func (*Store) CountTenantsByStatus ¶
CountTenantsByStatus returns the number of tenants in a given status.
func (*Store) DeleteCertificate ¶
DeleteCertificate removes a certificate.
func (*Store) DeleteCheck ¶
DeleteCheck removes a health check.
func (*Store) DeleteDomain ¶
DeleteDomain removes a domain.
func (*Store) DeleteRoute ¶
DeleteRoute removes a route.
func (*Store) DeleteSecret ¶
func (s *Store) DeleteSecret(ctx context.Context, tenantID string, instanceID id.ID, key string) error
DeleteSecret removes a secret by instance ID and key.
func (*Store) DeleteTenant ¶
DeleteTenant removes a tenant.
func (*Store) GetByID ¶
func (s *Store) GetByID(ctx context.Context, tenantID string, instanceID id.ID) (*instance.Instance, error)
GetByID retrieves an instance by its ID within a tenant.
func (*Store) GetBySlug ¶
func (s *Store) GetBySlug(ctx context.Context, tenantID string, slug string) (*instance.Instance, error)
GetBySlug retrieves an instance by its slug within a tenant.
func (*Store) GetCertificate ¶
func (s *Store) GetCertificate(ctx context.Context, tenantID string, certID id.ID) (*network.Certificate, error)
GetCertificate retrieves a certificate by ID.
func (*Store) GetCheck ¶
func (s *Store) GetCheck(ctx context.Context, tenantID string, checkID id.ID) (*health.HealthCheck, error)
GetCheck retrieves a health check by ID.
func (*Store) GetDeployment ¶
func (s *Store) GetDeployment(ctx context.Context, tenantID string, deployID id.ID) (*deploy.Deployment, error)
GetDeployment retrieves a deployment by ID within a tenant.
func (*Store) GetDomain ¶
func (s *Store) GetDomain(ctx context.Context, tenantID string, domainID id.ID) (*network.Domain, error)
GetDomain retrieves a domain by ID.
func (*Store) GetDomainByHostname ¶
GetDomainByHostname retrieves a domain by its hostname.
func (*Store) GetLatestResourceSnapshot ¶
func (s *Store) GetLatestResourceSnapshot(ctx context.Context, tenantID string, instanceID id.ID) (*telemetry.ResourceSnapshot, error)
GetLatestResourceSnapshot returns the most recent snapshot for an instance.
func (*Store) GetLatestResult ¶
func (s *Store) GetLatestResult(ctx context.Context, tenantID string, checkID id.ID) (*health.HealthResult, error)
GetLatestResult returns the most recent result for a check.
func (*Store) GetRelease ¶
func (s *Store) GetRelease(ctx context.Context, tenantID string, releaseID id.ID) (*deploy.Release, error)
GetRelease retrieves a release by ID within a tenant.
func (*Store) GetRoute ¶
func (s *Store) GetRoute(ctx context.Context, tenantID string, routeID id.ID) (*network.Route, error)
GetRoute retrieves a route by ID.
func (*Store) GetSecretByKey ¶
func (s *Store) GetSecretByKey(ctx context.Context, tenantID string, instanceID id.ID, key string) (*secrets.Secret, error)
GetSecretByKey retrieves a secret by instance ID and key.
func (*Store) GetTenantBySlug ¶
GetTenantBySlug retrieves a tenant by slug.
func (*Store) InsertAuditEntry ¶
InsertAuditEntry persists an audit log entry.
func (*Store) InsertCertificate ¶
InsertCertificate persists a new certificate.
func (*Store) InsertCheck ¶
InsertCheck persists a new health check configuration.
func (*Store) InsertDeployment ¶
InsertDeployment persists a new deployment.
func (*Store) InsertDomain ¶
InsertDomain persists a new domain.
func (*Store) InsertLogs ¶
InsertLogs persists log entries.
func (*Store) InsertMetrics ¶
InsertMetrics persists metric data points.
func (*Store) InsertRelease ¶
InsertRelease persists a new release.
func (*Store) InsertResourceSnapshot ¶
InsertResourceSnapshot persists a resource snapshot.
func (*Store) InsertResult ¶
InsertResult persists a health check result.
func (*Store) InsertRoute ¶
InsertRoute persists a new route.
func (*Store) InsertSecret ¶
InsertSecret persists a new secret.
func (*Store) InsertTenant ¶
InsertTenant persists a new tenant.
func (*Store) InsertTraces ¶
InsertTraces persists trace spans.
func (*Store) List ¶
func (s *Store) List(ctx context.Context, tenantID string, opts instance.ListOptions) (*instance.ListResult, error)
List returns a filtered, paginated list of instances for a tenant.
func (*Store) ListCertificates ¶
func (s *Store) ListCertificates(ctx context.Context, tenantID string, instanceID id.ID) ([]network.Certificate, error)
ListCertificates returns all certificates for an instance. It looks up domains owned by the instance, then finds certificates by domain IDs.
func (*Store) ListChecks ¶
func (s *Store) ListChecks(ctx context.Context, tenantID string, instanceID id.ID) ([]health.HealthCheck, error)
ListChecks returns all health checks for an instance.
func (*Store) ListDeployments ¶
func (s *Store) ListDeployments(ctx context.Context, tenantID string, instanceID id.ID, opts deploy.ListOptions) (*deploy.DeployListResult, error)
ListDeployments returns a filtered, paginated list of deployments for an instance.
func (*Store) ListDomains ¶
func (s *Store) ListDomains(ctx context.Context, tenantID string, instanceID id.ID) ([]network.Domain, error)
ListDomains returns all domains for an instance.
func (*Store) ListReleases ¶
func (s *Store) ListReleases(ctx context.Context, tenantID string, instanceID id.ID, opts deploy.ListOptions) (*deploy.ReleaseListResult, error)
ListReleases returns a filtered, paginated list of releases for an instance.
func (*Store) ListResourceSnapshots ¶
func (s *Store) ListResourceSnapshots(ctx context.Context, tenantID string, instanceID id.ID, opts telemetry.TimeRange) ([]telemetry.ResourceSnapshot, error)
ListResourceSnapshots returns snapshots for an instance within a time range.
func (*Store) ListResults ¶
func (s *Store) ListResults(ctx context.Context, tenantID string, checkID id.ID, opts health.HistoryOptions) ([]health.HealthResult, error)
ListResults returns health results for a check within a time range.
func (*Store) ListRoutes ¶
func (s *Store) ListRoutes(ctx context.Context, tenantID string, instanceID id.ID) ([]network.Route, error)
ListRoutes returns all routes for an instance.
func (*Store) ListSecrets ¶
func (s *Store) ListSecrets(ctx context.Context, tenantID string, instanceID id.ID) ([]secrets.Secret, error)
ListSecrets returns all secrets for an instance (values omitted).
func (*Store) ListTenants ¶
func (s *Store) ListTenants(ctx context.Context, opts admin.ListTenantsOptions) (*admin.TenantListResult, error)
ListTenants returns tenants with optional filtering.
func (*Store) NextReleaseVersion ¶
func (s *Store) NextReleaseVersion(ctx context.Context, tenantID string, instanceID id.ID) (int, error)
NextReleaseVersion returns the next auto-incrementing version number for an instance.
func (*Store) QueryAuditLog ¶
func (s *Store) QueryAuditLog(ctx context.Context, opts admin.AuditQuery) (*admin.AuditResult, error)
QueryAuditLog returns audit entries matching the query.
func (*Store) QueryMetrics ¶
func (s *Store) QueryMetrics(ctx context.Context, q telemetry.MetricQuery) ([]telemetry.Metric, error)
QueryMetrics returns metrics matching the query parameters.
func (*Store) QueryTraces ¶
QueryTraces returns traces matching the query parameters.
func (*Store) UpdateCertificate ¶
UpdateCertificate persists changes to a certificate.
func (*Store) UpdateCheck ¶
UpdateCheck persists changes to a health check.
func (*Store) UpdateDeployment ¶
UpdateDeployment persists changes to an existing deployment.
func (*Store) UpdateDomain ¶
UpdateDomain persists changes to a domain.
func (*Store) UpdateRoute ¶
UpdateRoute persists changes to a route.
func (*Store) UpdateSecret ¶
UpdateSecret persists changes to a secret.