Documentation
¶
Overview ¶
Package repo selects between concrete service.Repository / service.DB drivers (entdb, postgres, memory) for the production binary's wiring code.
Each driver lives in its own sub-package — internal/repo/entdb for the EntDB-backed driver, internal/repo/postgres for the SQL driver, internal/repo/memory for the in-process store used by tests. The split keeps each driver's dependencies isolated (entdb pulls in the SDK; postgres pulls in pgx; memory pulls in nothing).
Index ¶
- func NewDBAdapter(client *sdk.DbClient) (service.DB, error)
- type Built
- func (b *Built) ControlPlaneStore() service.ControlPlaneProjectStore
- func (b *Built) DomainStoreIface() service.DomainStore
- func (b *Built) InvitationStoreIface() service.InvitationStore
- func (b *Built) LoginGovernance() *service.LoginGovernance
- func (b *Built) MembershipStoreIface() service.MembershipStore
- func (b *Built) PlatformAdminStoreIface() service.PlatformAdminStore
- func (b *Built) ProjectResolver() service.ProjectResolver
- func (b *Built) TenantAutoFormer() service.TenantAutoFormStore
- func (b *Built) TenantStoreIface() service.TenantStore
- type Config
- type Driver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDBAdapter ¶
NewDBAdapter exposes the SDK's raw transport as service.DB. The service.DB contract is already the transport contract: tenant id, actor, numeric type ids, field-id-keyed filters, and raw entdb.Operation batches. Going through the SDK's typed Query/Get helpers here loses node ids on query results, so the adapter must delegate to the raw transport instead of translating through typed witnesses.
tenant-shard-db v1.14.0 (#528) exposes *DbClient.Transport() as a public read-only accessor, so the adapter reaches through it directly. Before v1.14.0 identity used an unsafe-reflection helper to do the same — that helper is gone.
Types ¶
type Built ¶
type Built struct {
Repository service.Repository
DB service.DB
// ProjectStore is the control-plane registry store. It is non-nil
// ONLY for the postgres driver — projects are a control-plane concern
// and entdb/memory have no control plane. The composition root uses it
// to seed the default project on boot. It shares Repository's pool, so
// closing the repository releases it too; do not close it separately.
ProjectStore *pgrepo.ProjectStore
// AutoFormStore auto-forms a company tenant from a new user's email
// domain at signup. Non-nil ONLY for the postgres driver; shares
// Repository's pool.
AutoFormStore *pgrepo.AutoFormStore
// DomainStore, TenantStore, MembershipStore and LoginPolicyStore are the
// per-project governance stores. They back the tenant domain-verification
// RPCs (DomainStore/TenantStore/MembershipStore) and the login path's
// LoginPolicy enforcement (TenantStore/DomainStore/LoginPolicyStore).
// Non-nil ONLY for the postgres driver (the only one with a governance
// plane); each shares Repository's pool.
DomainStore *pgrepo.DomainStore
TenantStore *pgrepo.TenantStore
MembershipStore *pgrepo.MembershipStore
LoginPolicyStore *pgrepo.LoginPolicyStore
// InvitationStore backs the tenant-invitation RPCs. Non-nil ONLY for the
// postgres driver; shares Repository's pool.
InvitationStore *pgrepo.InvitationStore
// PlatformAdminStore backs the zero-config first-admin bootstrap
// (CreateFirstPlatformAdmin). Non-nil ONLY for the postgres driver (the
// only one with a platform_admins table); shares Repository's pool.
PlatformAdminStore *pgrepo.PlatformAdminStore
}
Built bundles the constructed Repository + DB pair so callers can wire them into the service layer in one shot.
func (*Built) ControlPlaneStore ¶ added in v0.19.0
func (b *Built) ControlPlaneStore() service.ControlPlaneProjectStore
ControlPlaneStore returns the control-plane project write-store as the driver-agnostic service.ControlPlaneProjectStore the admin RPCs use, or a true nil when this build has no control plane (entdb/memory) — avoiding the typed-nil trap.
func (*Built) DomainStoreIface ¶ added in v0.17.0
func (b *Built) DomainStoreIface() service.DomainStore
DomainStoreIface returns the domain governance store as a driver-agnostic interface, or a true nil when this build has no control plane (entdb/memory) — avoiding the typed-nil trap.
func (*Built) InvitationStoreIface ¶ added in v0.18.0
func (b *Built) InvitationStoreIface() service.InvitationStore
InvitationStoreIface returns the invitation governance store as a driver-agnostic interface, or a true nil when this build has no control plane (entdb/memory) — avoiding the typed-nil trap.
func (*Built) LoginGovernance ¶ added in v0.17.0
func (b *Built) LoginGovernance() *service.LoginGovernance
LoginGovernance returns the read-side governance bundle the login path consults to enforce a claimed tenant's LoginPolicy, or a true nil when this build has no governance plane (entdb/memory). Returning nil — rather than a bundle of typed-nil stores — keeps AuthService's nil check honest.
func (*Built) MembershipStoreIface ¶ added in v0.17.0
func (b *Built) MembershipStoreIface() service.MembershipStore
MembershipStoreIface returns the membership governance store as a driver-agnostic interface, or a true nil when this build has no control plane (entdb/memory) — avoiding the typed-nil trap.
func (*Built) PlatformAdminStoreIface ¶ added in v1.1.0
func (b *Built) PlatformAdminStoreIface() service.PlatformAdminStore
PlatformAdminStoreIface returns the platform-admin store as a driver-agnostic interface, or a true nil when this build has no control plane (entdb/memory) — avoiding the typed-nil trap.
func (*Built) ProjectResolver ¶ added in v0.16.0
func (b *Built) ProjectResolver() service.ProjectResolver
ProjectResolver returns the control-plane project resolver as a driver-agnostic interface, or a true nil when this build has no control plane (entdb/memory). It exists so callers avoid the typed-nil trap: assigning a nil *ProjectStore straight into a service.ProjectResolver variable yields a non-nil interface wrapping a nil pointer.
func (*Built) TenantAutoFormer ¶ added in v0.17.0
func (b *Built) TenantAutoFormer() service.TenantAutoFormStore
TenantAutoFormer returns the tenant auto-formation store as a driver-agnostic interface, or a true nil when this build has no control plane (entdb/memory) — avoiding the typed-nil trap.
func (*Built) TenantStoreIface ¶ added in v0.17.0
func (b *Built) TenantStoreIface() service.TenantStore
TenantStoreIface returns the tenant governance store as a driver-agnostic interface, or a true nil when this build has no control plane (entdb/memory) — avoiding the typed-nil trap.
type Config ¶
type Config struct {
// Driver is the chosen backend. Required.
Driver Driver
// EntDBClient is the EntDB SDK client (entdb driver only).
EntDBClient *sdk.DbClient
// ProjectID is the storage shard the boot-default Repository/DB binds
// to (ADR-0002): the Project is identity's isolation shard, so the
// data-plane partition is the project id. Per-request scopes are derived
// from it via WithProject. Required for entdb and postgres.
ProjectID string
// Postgres-specific.
PostgresDSN string
PostgresMaxConns int
PostgresAutoMigrate bool
// RequireVerifiedAuthDomain restricts a project's primary auth-domain
// (the host that drives branded link URLs) to DNS-verified hostnames
// when true (the safe default). When false, a deployer opts into letting
// an unverified is_primary host drive branded links. Threaded into the
// postgres ProjectStore resolver.
RequireVerifiedAuthDomain bool
}
Config selects which driver to build and carries the parameters each driver needs.
type Driver ¶
type Driver string
Driver names a concrete persistence backend.
const ( // DriverEntDB targets the EntDB gRPC server via the typed SDK. DriverEntDB Driver = "entdb" // DriverPostgres targets a Postgres database via pgx/v5. DriverPostgres Driver = "postgres" // DriverMemory targets a process-local in-memory store, useful // for unit tests and local development. DriverMemory Driver = "memory" )
Directories
¶
| Path | Synopsis |
|---|---|
|
Package conformance is a driver-agnostic test suite for service.Repository implementations.
|
Package conformance is a driver-agnostic test suite for service.Repository implementations. |
|
Package entdb is the EntDB-backed implementation of service.Repository.
|
Package entdb is the EntDB-backed implementation of service.Repository. |
|
entclient
Package entclient is identity's blessed wrapper around the tenant-shard-db Go SDK constructor.
|
Package entclient is identity's blessed wrapper around the tenant-shard-db Go SDK constructor. |
|
Package memory is the in-process Repository driver.
|
Package memory is the in-process Repository driver. |
|
Package postgres provides a Postgres-backed implementation of service.Repository for the identity service.
|
Package postgres provides a Postgres-backed implementation of service.Repository for the identity service. |