Documentation
¶
Index ¶
- Constants
- func DocStoreErrorf(code DocStoreErrorCode, format string, a ...any) error
- func EnsureCoreSchema(ctx context.Context, store SchemaStore) error
- func EnsureSchema(ctx context.Context, store SchemaStore, name string, version string, ...) error
- func EntityRefToRPC(ref []revisor.EntityRef) []*repository.EntityRef
- func EventToRPC(evt Event) *repository.EventlogItem
- func IsDocStoreErrorCode(err error, code DocStoreErrorCode) bool
- func IsValidPermission(p Permission) bool
- func ListenAndServe(ctx context.Context, addr string, h http.Handler) error
- func RequireAnyScope(ctx context.Context, scopes ...string) (*elephantine.AuthInfo, error)
- func S3Client(ctx context.Context, opts S3Options) (*s3.Client, error)
- func SetUpRouter(router *httprouter.Router, opts ...RouterOption) error
- func Subscope(scope string, resource ...string) string
- func ToMetricAggregation(a Aggregation) (repository.MetricAggregation, error)
- func ValidateLabel(label string) error
- type ACLEntry
- type Aggregation
- type ArchiveEventType
- type ArchiveReader
- func (a *ArchiveReader) ReadDeleteManifest(ctx context.Context, key string) (_ *DeleteManifest, _ string, outErr error)
- func (a *ArchiveReader) ReadDocumentStatus(ctx context.Context, key string, parentSignature *string) (*ArchivedDocumentStatus, string, error)
- func (a *ArchiveReader) ReadDocumentVersion(ctx context.Context, key string, parentSignature *string) (_ *ArchivedDocumentVersion, _ string, outErr error)
- type ArchiveReaderOptions
- type ArchiveSignature
- type ArchivedDocumentStatus
- type ArchivedDocumentVersion
- type ArchivedEvent
- type ArchivedObject
- type Archiver
- type ArchiverOptions
- type BulkCheckPermissionRequest
- type BulkGetItem
- type BulkGetReference
- type CheckPermissionRequest
- type CheckPermissionResult
- type DeleteManifest
- type DeleteRecord
- type DeleteRequest
- type Deprecation
- type DeprecationEvent
- type DocStore
- type DocStoreError
- type DocStoreErrorCode
- type DocumentMeta
- type DocumentMetaType
- type DocumentStatus
- type DocumentUpdate
- type DocumentValidator
- type DocumentWorkflow
- type DocumentWorkflowConfiguration
- type DocumentsService
- func (a *DocumentsService) BulkGet(ctx context.Context, req *repository.BulkGetRequest) (*repository.BulkGetResponse, error)
- func (a *DocumentsService) BulkUpdate(ctx context.Context, req *repository.BulkUpdateRequest) (*repository.BulkUpdateResponse, error)
- func (a *DocumentsService) CompactedEventlog(ctx context.Context, req *repository.GetCompactedEventlogRequest) (*repository.GetCompactedEventlogResponse, error)
- func (a *DocumentsService) Delete(ctx context.Context, req *repository.DeleteDocumentRequest) (*repository.DeleteDocumentResponse, error)
- func (a *DocumentsService) Eventlog(ctx context.Context, req *repository.GetEventlogRequest) (*repository.GetEventlogResponse, error)
- func (a *DocumentsService) ExtendLock(ctx context.Context, req *repository.ExtendLockRequest) (*repository.LockResponse, error)
- func (a *DocumentsService) Get(ctx context.Context, req *repository.GetDocumentRequest) (*repository.GetDocumentResponse, error)
- func (a *DocumentsService) GetHistory(ctx context.Context, req *repository.GetHistoryRequest) (*repository.GetHistoryResponse, error)
- func (a *DocumentsService) GetMeta(ctx context.Context, req *repository.GetMetaRequest) (*repository.GetMetaResponse, error)
- func (a *DocumentsService) GetPermissions(ctx context.Context, req *repository.GetPermissionsRequest) (*repository.GetPermissionsResponse, error)
- func (a *DocumentsService) GetStatus(ctx context.Context, req *repository.GetStatusRequest) (*repository.GetStatusResponse, error)
- func (a *DocumentsService) GetStatusHistory(ctx context.Context, req *repository.GetStatusHistoryRequest) (*repository.GetStatusHistoryReponse, error)
- func (a *DocumentsService) GetStatusOverview(ctx context.Context, req *repository.GetStatusOverviewRequest) (*repository.GetStatusOverviewResponse, error)
- func (a *DocumentsService) ListDeleted(ctx context.Context, req *repository.ListDeletedRequest) (*repository.ListDeletedResponse, error)
- func (a *DocumentsService) Lock(ctx context.Context, req *repository.LockRequest) (*repository.LockResponse, error)
- func (a *DocumentsService) Purge(ctx context.Context, req *repository.PurgeRequest) (*repository.PurgeResponse, error)
- func (a *DocumentsService) Restore(ctx context.Context, req *repository.RestoreRequest) (*repository.RestoreResponse, error)
- func (a *DocumentsService) Unlock(ctx context.Context, req *repository.UnlockRequest) (*repository.UnlockResponse, error)
- func (a *DocumentsService) Update(ctx context.Context, req *repository.UpdateRequest) (*repository.UpdateResponse, error)
- func (a *DocumentsService) Validate(ctx context.Context, req *repository.ValidateRequest) (*repository.ValidateResponse, error)
- type EnforcedDeprecations
- type Event
- type EventType
- type FanOut
- type GetCompactedEventlogRequest
- type Lock
- type LockRequest
- type LockResult
- type Metric
- type MetricKind
- type MetricStore
- type MetricsService
- func (m *MetricsService) DeleteKind(ctx context.Context, req *repository.DeleteMetricKindRequest) (*repository.DeleteMetricKindResponse, error)
- func (m *MetricsService) GetKinds(ctx context.Context, _ *repository.GetMetricKindsRequest) (*repository.GetMetricKindsResponse, error)
- func (m *MetricsService) GetMetrics(_ context.Context, _ *repository.GetMetricsRequest) (*repository.GetMetricsResponse, error)
- func (m *MetricsService) RegisterKind(ctx context.Context, req *repository.RegisterMetricKindRequest) (*repository.RegisterMetricKindResponse, error)
- func (m *MetricsService) RegisterMetric(ctx context.Context, req *repository.RegisterMetricRequest) (*repository.RegisterMetricResponse, error)
- type NotifyChannel
- type PGDocStore
- func (s *PGDocStore) ActivateSchema(ctx context.Context, name, version string) error
- func (s *PGDocStore) BulkCheckPermissions(ctx context.Context, req BulkCheckPermissionRequest) ([]uuid.UUID, error)
- func (s *PGDocStore) BulkGetDocuments(ctx context.Context, documents []BulkGetReference) ([]BulkGetItem, error)
- func (s *PGDocStore) CheckPermissions(ctx context.Context, req CheckPermissionRequest) (CheckPermissionResult, error)
- func (s *PGDocStore) DeactivateSchema(ctx context.Context, name string) (outErr error)
- func (s *PGDocStore) Delete(ctx context.Context, req DeleteRequest) (outErr error)
- func (s *PGDocStore) DeleteDocumentWorkflow(ctx context.Context, docType string) error
- func (s *PGDocStore) DeleteMetricKind(ctx context.Context, name string) error
- func (s *PGDocStore) DeleteStatusRule(ctx context.Context, docType string, name string) error
- func (s *PGDocStore) GetActiveSchemas(ctx context.Context) ([]*Schema, error)
- func (s *PGDocStore) GetCompactedEventlog(ctx context.Context, req GetCompactedEventlogRequest) ([]Event, error)
- func (s *PGDocStore) GetDeprecations(ctx context.Context) ([]*Deprecation, error)
- func (s *PGDocStore) GetDocument(ctx context.Context, uuid uuid.UUID, version int64) (*newsdoc.Document, int64, error)
- func (s *PGDocStore) GetDocumentACL(ctx context.Context, uuid uuid.UUID) ([]ACLEntry, error)
- func (s *PGDocStore) GetDocumentMeta(ctx context.Context, docID uuid.UUID) (*DocumentMeta, error)
- func (s *PGDocStore) GetDocumentWorkflow(ctx context.Context, docType string) (DocumentWorkflow, error)
- func (s *PGDocStore) GetDocumentWorkflows(ctx context.Context) ([]DocumentWorkflow, error)
- func (s *PGDocStore) GetEnforcedDeprecations(ctx context.Context) (EnforcedDeprecations, error)
- func (s *PGDocStore) GetEventlog(ctx context.Context, after int64, limit int32) ([]Event, error)
- func (s *PGDocStore) GetLastEvent(ctx context.Context) (*Event, error)
- func (s *PGDocStore) GetLastEventID(ctx context.Context) (int64, error)
- func (s *PGDocStore) GetMetaTypeForDocument(ctx context.Context, uuid uuid.UUID) (DocumentMetaType, error)
- func (s *PGDocStore) GetMetricKind(ctx context.Context, name string) (*MetricKind, error)
- func (s *PGDocStore) GetMetricKinds(ctx context.Context) ([]*MetricKind, error)
- func (s *PGDocStore) GetSchema(ctx context.Context, name string, version string) (*Schema, error)
- func (s *PGDocStore) GetSchemaVersions(ctx context.Context) (map[string]string, error)
- func (s *PGDocStore) GetSinkPosition(ctx context.Context, name string) (int64, error)
- func (s *PGDocStore) GetStatus(ctx context.Context, uuid uuid.UUID, name string, id int64) (Status, error)
- func (s *PGDocStore) GetStatusHistory(ctx context.Context, uuid uuid.UUID, name string, before int64, count int) ([]Status, error)
- func (s *PGDocStore) GetStatusOverview(ctx context.Context, uuids []uuid.UUID, statuses []string, getMeta bool) ([]StatusOverviewItem, error)
- func (s *PGDocStore) GetStatusRules(ctx context.Context) ([]StatusRule, error)
- func (s *PGDocStore) GetStatuses(ctx context.Context) ([]DocumentStatus, error)
- func (s *PGDocStore) GetTypeOfDocument(ctx context.Context, uuid uuid.UUID) (string, error)
- func (s *PGDocStore) GetVersion(ctx context.Context, uuid uuid.UUID, version int64) (DocumentUpdate, error)
- func (s *PGDocStore) GetVersionHistory(ctx context.Context, uuid uuid.UUID, before int64, count int) ([]DocumentUpdate, error)
- func (s *PGDocStore) ListDeleteRecords(ctx context.Context, docUUID *uuid.UUID, beforeID int64, beforeTime *time.Time) ([]DeleteRecord, error)
- func (s *PGDocStore) Lock(ctx context.Context, req LockRequest) (LockResult, error)
- func (s *PGDocStore) OnArchivedUpdate(ctx context.Context, ch chan ArchivedEvent)
- func (s *PGDocStore) OnDeprecationUpdate(ctx context.Context, ch chan DeprecationEvent)
- func (s *PGDocStore) OnEventlog(ctx context.Context, ch chan int64)
- func (s *PGDocStore) OnSchemaUpdate(ctx context.Context, ch chan SchemaEvent)
- func (s *PGDocStore) OnWorkflowUpdate(ctx context.Context, ch chan WorkflowEvent)
- func (s *PGDocStore) PurgeDocument(ctx context.Context, docUUID uuid.UUID, deleteRecordID int64, creator string) (outErr error)
- func (s *PGDocStore) RegisterMetaType(ctx context.Context, metaType string, exclusive bool) error
- func (s *PGDocStore) RegisterMetaTypeUse(ctx context.Context, mainType string, metaType string) error
- func (s *PGDocStore) RegisterMetricKind(ctx context.Context, name string, aggregation Aggregation) error
- func (s *PGDocStore) RegisterOrIncrementMetric(ctx context.Context, metric Metric) error
- func (s *PGDocStore) RegisterOrReplaceMetric(ctx context.Context, metric Metric) error
- func (s *PGDocStore) RegisterSchema(ctx context.Context, req RegisterSchemaRequest) error
- func (s *PGDocStore) RestoreDocument(ctx context.Context, docUUID uuid.UUID, deleteRecordID int64, creator string, ...) (outErr error)
- func (s *PGDocStore) RunCleaner(ctx context.Context, period time.Duration)
- func (s *PGDocStore) RunListener(ctx context.Context)
- func (s *PGDocStore) SetDocumentWorkflow(ctx context.Context, workflow DocumentWorkflow) error
- func (s *PGDocStore) SetSinkPosition(ctx context.Context, name string, pos int64) error
- func (s *PGDocStore) Unlock(ctx context.Context, uuid uuid.UUID, token string) error
- func (s *PGDocStore) Update(ctx context.Context, workflows WorkflowProvider, requests []*UpdateRequest) (_ []DocumentUpdate, outErr error)
- func (s *PGDocStore) UpdateDeprecation(ctx context.Context, deprecation Deprecation) error
- func (s *PGDocStore) UpdateLock(ctx context.Context, req UpdateLockRequest) (LockResult, error)
- func (s *PGDocStore) UpdatePreflight(ctx context.Context, q *postgres.Queries, docUUID uuid.UUID, ifMatch int64) (*UpdatePrefligthInfo, error)
- func (s *PGDocStore) UpdateStatus(ctx context.Context, req UpdateStatusRequest) error
- func (s *PGDocStore) UpdateStatusRule(ctx context.Context, rule StatusRule) error
- type PGDocStoreOptions
- type PGReplication
- type Permission
- type RegisterSchemaRequest
- type RestoreSpec
- type RouterOption
- func WithDocumentsAPI(service repository.Documents, opts ServerOptions) RouterOption
- func WithMetricsAPI(service repository.Metrics, opts ServerOptions) RouterOption
- func WithReportsAPI(service repository.Reports, opts ServerOptions) RouterOption
- func WithSSE(handler http.Handler, opt ServerOptions) RouterOption
- func WithSchemasAPI(service repository.Schemas, opts ServerOptions) RouterOption
- func WithWorkflowsAPI(service repository.Workflows, opts ServerOptions) RouterOption
- type S3Options
- type SSE
- type Schema
- type SchemaEvent
- type SchemaEventType
- type SchemaStore
- type SchemasService
- func (a *SchemasService) Get(ctx context.Context, req *repository.GetSchemaRequest) (*repository.GetSchemaResponse, error)
- func (a *SchemasService) GetAllActive(ctx context.Context, req *repository.GetAllActiveSchemasRequest) (*repository.GetAllActiveSchemasResponse, error)
- func (a *SchemasService) GetDeprecations(ctx context.Context, _ *repository.GetDeprecationsRequest) (*repository.GetDeprecationsResponse, error)
- func (a *SchemasService) Register(ctx context.Context, req *repository.RegisterSchemaRequest) (*repository.RegisterSchemaResponse, error)
- func (a *SchemasService) RegisterMetaType(ctx context.Context, req *repository.RegisterMetaTypeRequest) (*repository.RegisterMetaTypeResponse, error)
- func (a *SchemasService) RegisterMetaTypeUse(ctx context.Context, req *repository.RegisterMetaTypeUseRequest) (*repository.RegisterMetaTypeUseResponse, error)
- func (a *SchemasService) SetActive(ctx context.Context, req *repository.SetActiveSchemaRequest) (*repository.SetActiveSchemaResponse, error)
- func (a *SchemasService) UpdateDeprecation(ctx context.Context, req *repository.UpdateDeprecationRequest) (*repository.UpdateDeprecationResponse, error)
- type ServerOptions
- type SigningKey
- type SigningKeySet
- type Status
- type StatusOverviewItem
- type StatusRule
- type StatusRuleError
- type StatusRuleInput
- type StatusRuleViolation
- type StatusUpdate
- type SystemState
- type TokenResponse
- type TupleDecoder
- type UpdateLockRequest
- type UpdatePrefligthInfo
- type UpdateRequest
- type UpdateStatusRequest
- type Validator
- type ValidatorStore
- type WorkflowEvent
- type WorkflowEventType
- type WorkflowLoader
- type WorkflowProvider
- type WorkflowState
- type WorkflowStep
- type WorkflowStore
- type Workflows
- type WorkflowsService
- func (s *WorkflowsService) CreateStatusRule(ctx context.Context, req *repository.CreateStatusRuleRequest) (*repository.CreateStatusRuleResponse, error)
- func (s *WorkflowsService) DeleteStatusRule(ctx context.Context, req *repository.DeleteStatusRuleRequest) (*repository.DeleteStatusRuleResponse, error)
- func (s *WorkflowsService) DeleteWorkflow(ctx context.Context, req *repository.DeleteWorkflowRequest) (*repository.DeleteWorkflowResponse, error)
- func (s *WorkflowsService) GetStatusRules(ctx context.Context, _ *repository.GetStatusRulesRequest) (*repository.GetStatusRulesResponse, error)
- func (s *WorkflowsService) GetStatuses(ctx context.Context, _ *repository.GetStatusesRequest) (*repository.GetStatusesResponse, error)
- func (s *WorkflowsService) GetWorkflow(ctx context.Context, req *repository.GetWorkflowRequest) (*repository.GetWorkflowResponse, error)
- func (s *WorkflowsService) SetWorkflow(ctx context.Context, req *repository.SetWorkflowRequest) (*repository.SetWorkflowResponse, error)
- func (s *WorkflowsService) UpdateStatus(ctx context.Context, req *repository.UpdateStatusRequest) (*repository.UpdateStatusResponse, error)
Constants ¶
const ( VersionHistoryMaxCount = 50 StatusHistoryMaxCount = 50 )
const ( PermissionCheckDenied = iota PermissionCheckAllowed PermissionCheckNoSuchDocument PermissionCheckSystemLock )
const ( SystemStateDeleting = "deleting" SystemStateRestoring = "restoring" )
const ( ScopeDocumentAdmin = "doc_admin" ScopeDocumentReadAll = "doc_read_all" ScopeDocumentRead = "doc_read" ScopeDocumentDelete = "doc_delete" ScopeDocumentRestore = "doc_restore" ScopeDocumentPurge = "doc_purge" ScopeDocumentWrite = "doc_write" ScopeMetaDocumentWriteAll = "meta_doc_write_all" ScopeDocumentImport = "doc_import" ScopeEventlogRead = "eventlog_read" ScopeMetricsAdmin = "metrics_admin" ScopeMetricsWrite = "metrics_write" ScopeReportAdmin = "report_admin" ScopeReportRun = "report_run" ScopeSchemaAdmin = "schema_admin" ScopeSchemaRead = "schema_read" ScopeWorkflowAdmin = "workflow_admin" )
const ( LockSigningKeys = elephantCRC + 1 LockLogicalReplication = elephantCRC + 2 )
const ( LogKeyDeprecationLabel = "deprecation_label" LogKeyEntityRef = "entity_ref" )
const (
SQLCodeObjectInUse = "55006"
)
https://www.postgresql.org/docs/current/errcodes-appendix.html#ERRCODES-TABLE
Variables ¶
This section is empty.
Functions ¶
func DocStoreErrorf ¶
func DocStoreErrorf(code DocStoreErrorCode, format string, a ...any) error
func EnsureCoreSchema ¶
func EnsureCoreSchema(ctx context.Context, store SchemaStore) error
func EnsureSchema ¶
func EnsureSchema( ctx context.Context, store SchemaStore, name string, version string, schema revisor.ConstraintSet, ) error
func EntityRefToRPC ¶
func EntityRefToRPC(ref []revisor.EntityRef) []*repository.EntityRef
func EventToRPC ¶
func EventToRPC(evt Event) *repository.EventlogItem
func IsDocStoreErrorCode ¶
func IsDocStoreErrorCode(err error, code DocStoreErrorCode) bool
func IsValidPermission ¶ added in v0.4.6
func IsValidPermission(p Permission) bool
func RequireAnyScope ¶
func SetUpRouter ¶
func SetUpRouter( router *httprouter.Router, opts ...RouterOption, ) error
func ToMetricAggregation ¶
func ToMetricAggregation(a Aggregation) (repository.MetricAggregation, error)
func ValidateLabel ¶
Types ¶
type Aggregation ¶
type Aggregation int16
const ( AggregationNone Aggregation = 0 AggregationReplace Aggregation = 1 AggregationIncrement Aggregation = 2 )
func ToAggregation ¶
func ToAggregation(ma repository.MetricAggregation) (Aggregation, error)
type ArchiveEventType ¶
type ArchiveEventType int
const ( ArchiveEventTypeStatus ArchiveEventType = iota ArchiveEventTypeVersion )
type ArchiveReader ¶ added in v0.5.9
type ArchiveReader struct {
// contains filtered or unexported fields
}
func NewArchiveReader ¶ added in v0.5.9
func NewArchiveReader(opts ArchiveReaderOptions) *ArchiveReader
func (*ArchiveReader) ReadDeleteManifest ¶ added in v0.5.9
func (a *ArchiveReader) ReadDeleteManifest( ctx context.Context, key string, ) (_ *DeleteManifest, _ string, outErr error)
ReadDeleteManifest reads and verifies a delete manifest from the archive.
func (*ArchiveReader) ReadDocumentStatus ¶ added in v0.5.9
func (a *ArchiveReader) ReadDocumentStatus( ctx context.Context, key string, parentSignature *string, ) (*ArchivedDocumentStatus, string, error)
ReadDocumentStatus reads and verifies a document status from the archive. If parentSignature is provided the read version will be verified against it.
func (*ArchiveReader) ReadDocumentVersion ¶ added in v0.5.9
func (a *ArchiveReader) ReadDocumentVersion( ctx context.Context, key string, parentSignature *string, ) (_ *ArchivedDocumentVersion, _ string, outErr error)
ReadDocumentVersion reads and verifies a document version from the archive. If parentSignature is provided the read version will be verified against it.
type ArchiveReaderOptions ¶ added in v0.5.9
type ArchiveReaderOptions struct { S3 *s3.Client Bucket string SigningKeys *SigningKeySet }
type ArchiveSignature ¶
func NewArchiveSignature ¶
func NewArchiveSignature( key *SigningKey, hash [sha256.Size]byte, ) (*ArchiveSignature, error)
func ParseArchiveSignature ¶
func ParseArchiveSignature(sg string) (*ArchiveSignature, error)
func (*ArchiveSignature) String ¶
func (as *ArchiveSignature) String() string
func (*ArchiveSignature) Verify ¶
func (as *ArchiveSignature) Verify(key *SigningKey) error
type ArchivedDocumentStatus ¶
type ArchivedDocumentStatus struct { UUID uuid.UUID `json:"uuid"` Name string `json:"name"` ID int64 `json:"id"` Type string `json:"type"` Version int64 `json:"version"` Created time.Time `json:"created"` CreatorURI string `json:"creator_uri"` Meta json.RawMessage `json:"meta,omitempty"` ParentSignature string `json:"parent_signature,omitempty"` VersionSignature string `json:"version_signature"` Archived time.Time `json:"archived"` Language string `json:"language"` MetaDocVersion int64 `json:"meta_doc_version,omitempty"` }
func (*ArchivedDocumentStatus) GetArchivedTime ¶ added in v0.5.9
func (as *ArchivedDocumentStatus) GetArchivedTime() time.Time
func (*ArchivedDocumentStatus) GetParentSignature ¶ added in v0.5.9
func (as *ArchivedDocumentStatus) GetParentSignature() string
type ArchivedDocumentVersion ¶
type ArchivedDocumentVersion struct { UUID uuid.UUID `json:"uuid"` URI string `json:"uri"` Type string `json:"type"` Language string `json:"language"` Version int64 `json:"version"` Created time.Time `json:"created"` CreatorURI string `json:"creator_uri"` Meta json.RawMessage `json:"meta,omitempty"` DocumentData json.RawMessage `json:"document_data"` MainDocument *uuid.UUID `json:"main_document,omitempty"` ParentSignature string `json:"parent_signature,omitempty"` Archived time.Time `json:"archived"` }
func (*ArchivedDocumentVersion) GetArchivedTime ¶ added in v0.5.9
func (av *ArchivedDocumentVersion) GetArchivedTime() time.Time
func (*ArchivedDocumentVersion) GetParentSignature ¶ added in v0.5.9
func (av *ArchivedDocumentVersion) GetParentSignature() string
type ArchivedEvent ¶
type ArchivedEvent struct { Type ArchiveEventType `json:"type"` UUID uuid.UUID `json:"uuid"` // Version is the version of a document or the ID of a status. Version int64 `json:"version"` Name string `json:"name,omitempty"` }
type ArchivedObject ¶ added in v0.5.9
type Archiver ¶
type Archiver struct {
// contains filtered or unexported fields
}
Archiver reads unarchived document versions, and statuses and writes a copy to S3. It does this using SELECT ... FOR UPDATE SKIP LOCKED.
func NewArchiver ¶
func NewArchiver(opts ArchiverOptions) (*Archiver, error)
type ArchiverOptions ¶
type ArchiverOptions struct { Logger *slog.Logger S3 *s3.Client Bucket string DB *pgxpool.Pool MetricsRegisterer prometheus.Registerer }
type BulkCheckPermissionRequest ¶ added in v0.5.9
type BulkCheckPermissionRequest struct { UUIDs []uuid.UUID GranteeURIs []string Permissions []Permission }
type BulkGetItem ¶ added in v0.7.5
type BulkGetReference ¶ added in v0.7.5
type CheckPermissionRequest ¶
type CheckPermissionRequest struct { UUID uuid.UUID GranteeURIs []string Permissions []Permission }
type CheckPermissionResult ¶
type CheckPermissionResult int
type DeleteManifest ¶ added in v0.5.9
type DeleteManifest struct { LastVersion int64 `json:"last_version"` Heads map[string]int64 `json:"heads"` ACL []ACLEntry `json:"acl"` Archived time.Time `json:"archived"` }
func (*DeleteManifest) GetArchivedTime ¶ added in v0.5.9
func (m *DeleteManifest) GetArchivedTime() time.Time
func (*DeleteManifest) GetParentSignature ¶ added in v0.5.9
func (m *DeleteManifest) GetParentSignature() string
type DeleteRecord ¶ added in v0.5.9
type DeleteRequest ¶
type Deprecation ¶ added in v0.5.1
type DeprecationEvent ¶ added in v0.5.1
type DeprecationEvent struct {
Label string `json:"label"`
}
type DocStore ¶
type DocStore interface { GetDocumentMeta( ctx context.Context, uuid uuid.UUID) (*DocumentMeta, error) GetDocument( ctx context.Context, uuid uuid.UUID, version int64, ) (*newsdoc.Document, int64, error) BulkGetDocuments( ctx context.Context, documents []BulkGetReference, ) ([]BulkGetItem, error) GetVersion( ctx context.Context, uuid uuid.UUID, version int64, ) (DocumentUpdate, error) // GetVersionHistory of a document. Count cannot be greater than // VersionHistoryMaxCount. GetVersionHistory( ctx context.Context, uuid uuid.UUID, before int64, count int, ) ([]DocumentUpdate, error) Update( ctx context.Context, workflows WorkflowProvider, update []*UpdateRequest, ) ([]DocumentUpdate, error) Delete(ctx context.Context, req DeleteRequest) error ListDeleteRecords( ctx context.Context, docUUID *uuid.UUID, beforeID int64, startDate *time.Time, ) ([]DeleteRecord, error) RestoreDocument( ctx context.Context, docUUID uuid.UUID, deleteRecordID int64, creator string, acl []ACLEntry, ) error PurgeDocument( ctx context.Context, docUUID uuid.UUID, deleteRecordID int64, creator string, ) error CheckPermissions( ctx context.Context, req CheckPermissionRequest, ) (CheckPermissionResult, error) BulkCheckPermissions( ctx context.Context, req BulkCheckPermissionRequest, ) ([]uuid.UUID, error) GetTypeOfDocument( ctx context.Context, uuid uuid.UUID, ) (string, error) GetMetaTypeForDocument( ctx context.Context, uuid uuid.UUID, ) (DocumentMetaType, error) RegisterMetaType( ctx context.Context, metaType string, exclusive bool, ) error RegisterMetaTypeUse( ctx context.Context, mainType string, metaType string, ) error GetEventlog( ctx context.Context, after int64, limit int32, ) ([]Event, error) GetLastEvent( ctx context.Context, ) (*Event, error) GetLastEventID( ctx context.Context, ) (int64, error) GetCompactedEventlog( ctx context.Context, req GetCompactedEventlogRequest, ) ([]Event, error) OnEventlog( ctx context.Context, ch chan int64, ) GetStatus( ctx context.Context, uuid uuid.UUID, name string, id int64, ) (Status, error) // GetStatusHistory of a document. Count cannot be greater than // StatusHistoryMaxCount. GetStatusHistory( ctx context.Context, uuid uuid.UUID, name string, before int64, count int, ) ([]Status, error) GetStatusOverview( ctx context.Context, uuids []uuid.UUID, statuses []string, getMeta bool, ) ([]StatusOverviewItem, error) GetDocumentACL( ctx context.Context, uuid uuid.UUID, ) ([]ACLEntry, error) Lock( ctx context.Context, req LockRequest, ) (LockResult, error) UpdateLock( ctx context.Context, req UpdateLockRequest, ) (LockResult, error) Unlock( ctx context.Context, uuid uuid.UUID, token string, ) error }
type DocStoreError ¶
type DocStoreError struct {
// contains filtered or unexported fields
}
func (DocStoreError) Error ¶
func (e DocStoreError) Error() string
func (DocStoreError) Unwrap ¶
func (e DocStoreError) Unwrap() error
type DocStoreErrorCode ¶
type DocStoreErrorCode string
DocStoreErrorCode TODO: Rename to StoreErrorCode and consistently rename all dependent types and methods.
const ( NoErrCode DocStoreErrorCode = "" ErrCodeNotFound DocStoreErrorCode = "not-found" ErrCodeNoSuchLock DocStoreErrorCode = "no-such-lock" ErrCodeOptimisticLock DocStoreErrorCode = "optimistic-lock" ErrCodeDeleteLock DocStoreErrorCode = "delete-lock" ErrCodeSystemLock DocStoreErrorCode = "system-lock" ErrCodeBadRequest DocStoreErrorCode = "bad-request" ErrCodeExists DocStoreErrorCode = "exists" ErrCodePermissionDenied DocStoreErrorCode = "permission-denied" ErrCodeFailedPrecondition DocStoreErrorCode = "failed-precondition" ErrCodeDocumentLock DocStoreErrorCode = "document-lock" ErrCodeDuplicateURI DocStoreErrorCode = "duplicate-uri" )
func GetDocStoreErrorCode ¶
func GetDocStoreErrorCode(err error) DocStoreErrorCode
type DocumentMeta ¶
type DocumentMetaType ¶ added in v0.4.6
type DocumentStatus ¶
type DocumentUpdate ¶
type DocumentValidator ¶
type DocumentWorkflow ¶ added in v0.9.0
type DocumentWorkflow struct { Type string Updated time.Time UpdaterURI string Configuration DocumentWorkflowConfiguration }
func (DocumentWorkflow) Start ¶ added in v0.9.0
func (wf DocumentWorkflow) Start() WorkflowState
func (DocumentWorkflow) Step ¶ added in v0.9.0
func (wf DocumentWorkflow) Step(state WorkflowState, step WorkflowStep) WorkflowState
type DocumentWorkflowConfiguration ¶ added in v0.9.0
type DocumentsService ¶
type DocumentsService struct {
// contains filtered or unexported fields
}
func NewDocumentsService ¶
func NewDocumentsService( store DocStore, validator DocumentValidator, workflows WorkflowProvider, defaultLanguage string, ) *DocumentsService
func (*DocumentsService) BulkGet ¶ added in v0.7.5
func (a *DocumentsService) BulkGet( ctx context.Context, req *repository.BulkGetRequest, ) (*repository.BulkGetResponse, error)
BulkGet implements repository.Documents.
func (*DocumentsService) BulkUpdate ¶ added in v0.4.0
func (a *DocumentsService) BulkUpdate( ctx context.Context, req *repository.BulkUpdateRequest, ) (*repository.BulkUpdateResponse, error)
BulkUpdate implements repository.Documents.
func (*DocumentsService) CompactedEventlog ¶ added in v0.4.0
func (a *DocumentsService) CompactedEventlog( ctx context.Context, req *repository.GetCompactedEventlogRequest, ) (*repository.GetCompactedEventlogResponse, error)
CompactedEventlog implements repository.Documents.
func (*DocumentsService) Delete ¶
func (a *DocumentsService) Delete( ctx context.Context, req *repository.DeleteDocumentRequest, ) (*repository.DeleteDocumentResponse, error)
Delete implements repository.Documents.
func (*DocumentsService) Eventlog ¶
func (a *DocumentsService) Eventlog( ctx context.Context, req *repository.GetEventlogRequest, ) (*repository.GetEventlogResponse, error)
Eventlog returns document update events, optionally waiting for new events.
func (*DocumentsService) ExtendLock ¶
func (a *DocumentsService) ExtendLock( ctx context.Context, req *repository.ExtendLockRequest, ) (*repository.LockResponse, error)
ExtendLock extends the expiration of an existing lock.
func (*DocumentsService) Get ¶
func (a *DocumentsService) Get( ctx context.Context, req *repository.GetDocumentRequest, ) (*repository.GetDocumentResponse, error)
Get implements repository.Documents.
func (*DocumentsService) GetHistory ¶
func (a *DocumentsService) GetHistory( ctx context.Context, req *repository.GetHistoryRequest, ) (*repository.GetHistoryResponse, error)
GetHistory implements repository.Documents.
func (*DocumentsService) GetMeta ¶
func (a *DocumentsService) GetMeta( ctx context.Context, req *repository.GetMetaRequest, ) (*repository.GetMetaResponse, error)
GetMeta implements repository.Documents.
func (*DocumentsService) GetPermissions ¶
func (a *DocumentsService) GetPermissions( ctx context.Context, req *repository.GetPermissionsRequest, ) (*repository.GetPermissionsResponse, error)
GetPermissions returns the permissions you have for the document.
func (*DocumentsService) GetStatus ¶ added in v0.8.1
func (a *DocumentsService) GetStatus( ctx context.Context, req *repository.GetStatusRequest, ) (*repository.GetStatusResponse, error)
GetStatus implements repository.Documents.
func (*DocumentsService) GetStatusHistory ¶
func (a *DocumentsService) GetStatusHistory( ctx context.Context, req *repository.GetStatusHistoryRequest, ) (*repository.GetStatusHistoryReponse, error)
GetStatusHistory returns the history of a status for a document.
func (*DocumentsService) GetStatusOverview ¶ added in v0.5.9
func (a *DocumentsService) GetStatusOverview( ctx context.Context, req *repository.GetStatusOverviewRequest, ) (*repository.GetStatusOverviewResponse, error)
GetStatusOverview implements repository.Documents.
func (*DocumentsService) ListDeleted ¶ added in v0.5.9
func (a *DocumentsService) ListDeleted( ctx context.Context, req *repository.ListDeletedRequest, ) (*repository.ListDeletedResponse, error)
ListDeleted implements repository.Documents.
func (*DocumentsService) Lock ¶
func (a *DocumentsService) Lock( ctx context.Context, req *repository.LockRequest, ) (*repository.LockResponse, error)
func (*DocumentsService) Purge ¶ added in v0.5.9
func (a *DocumentsService) Purge( ctx context.Context, req *repository.PurgeRequest, ) (*repository.PurgeResponse, error)
Purge implements repository.Documents.
func (*DocumentsService) Restore ¶ added in v0.5.9
func (a *DocumentsService) Restore( ctx context.Context, req *repository.RestoreRequest, ) (*repository.RestoreResponse, error)
Restore implements repository.Documents.
func (*DocumentsService) Unlock ¶
func (a *DocumentsService) Unlock( ctx context.Context, req *repository.UnlockRequest, ) (*repository.UnlockResponse, error)
func (*DocumentsService) Update ¶
func (a *DocumentsService) Update( ctx context.Context, req *repository.UpdateRequest, ) (*repository.UpdateResponse, error)
Update implements repository.Documents.
func (*DocumentsService) Validate ¶
func (a *DocumentsService) Validate( ctx context.Context, req *repository.ValidateRequest, ) (*repository.ValidateResponse, error)
Validate implements repository.Documents.
type EnforcedDeprecations ¶ added in v0.5.1
type Event ¶
type Event struct { ID int64 `json:"id"` Event EventType `json:"event"` UUID uuid.UUID `json:"uuid"` Timestamp time.Time `json:"timestamp"` Updater string `json:"updater"` Type string `json:"type"` Language string `json:"language"` OldLanguage string `json:"old_language,omitempty"` MainDocument *uuid.UUID `json:"main_document,omitempty"` Version int64 `json:"version,omitempty"` StatusID int64 `json:"status_id,omitempty"` Status string `json:"status,omitempty"` ACL []ACLEntry `json:"acl,omitempty"` SystemState string `json:"system_state,omitempty"` WorkflowStep string `json:"workflow_step,omitempty"` WorkflowCheckpoint string `json:"workflow_checkpoint,omitempty"` }
func RPCToEvent ¶
func RPCToEvent(evt *repository.EventlogItem) (Event, error)
type FanOut ¶
type FanOut[T any] struct { // contains filtered or unexported fields }
type GetCompactedEventlogRequest ¶ added in v0.4.0
type LockRequest ¶
type MetricKind ¶
type MetricKind struct { Name string Aggregation Aggregation }
type MetricStore ¶
type MetricStore interface { RegisterMetricKind( ctx context.Context, name string, aggregation Aggregation, ) error DeleteMetricKind( ctx context.Context, name string, ) error GetMetricKind( ctx context.Context, name string, ) (*MetricKind, error) GetMetricKinds( ctx context.Context, ) ([]*MetricKind, error) RegisterOrReplaceMetric( ctx context.Context, metric Metric, ) error RegisterOrIncrementMetric( ctx context.Context, metric Metric, ) error }
type MetricsService ¶
type MetricsService struct {
// contains filtered or unexported fields
}
func NewMetricsService ¶
func NewMetricsService(store MetricStore) *MetricsService
func (*MetricsService) DeleteKind ¶
func (m *MetricsService) DeleteKind( ctx context.Context, req *repository.DeleteMetricKindRequest, ) (*repository.DeleteMetricKindResponse, error)
DeleteKind implements repository.Metrics.
func (*MetricsService) GetKinds ¶
func (m *MetricsService) GetKinds( ctx context.Context, _ *repository.GetMetricKindsRequest, ) (*repository.GetMetricKindsResponse, error)
GetKinds implements repository.Metrics.
func (*MetricsService) GetMetrics ¶ added in v0.9.0
func (m *MetricsService) GetMetrics( _ context.Context, _ *repository.GetMetricsRequest, ) (*repository.GetMetricsResponse, error)
GetMetrics implements repository.Metrics.
func (*MetricsService) RegisterKind ¶
func (m *MetricsService) RegisterKind( ctx context.Context, req *repository.RegisterMetricKindRequest, ) (*repository.RegisterMetricKindResponse, error)
RegisterKind implements repository.Metrics.
func (*MetricsService) RegisterMetric ¶
func (m *MetricsService) RegisterMetric( ctx context.Context, req *repository.RegisterMetricRequest, ) (*repository.RegisterMetricResponse, error)
RegisterMetric implements repository.Metrics.
type NotifyChannel ¶
type NotifyChannel string
const ( NotifySchemasUpdated NotifyChannel = "schemas" NotifyDeprecationsUpdated NotifyChannel = "deprecations" NotifyArchived NotifyChannel = "archived" NotifyWorkflowsUpdated NotifyChannel = "workflows" NotifyEventlog NotifyChannel = "eventlog" )
type PGDocStore ¶
type PGDocStore struct {
// contains filtered or unexported fields
}
func NewPGDocStore ¶
func NewPGDocStore( logger *slog.Logger, pool *pgxpool.Pool, options PGDocStoreOptions, ) (*PGDocStore, error)
func (*PGDocStore) ActivateSchema ¶
func (s *PGDocStore) ActivateSchema( ctx context.Context, name, version string, ) error
RegisterSchema implements DocStore.
func (*PGDocStore) BulkCheckPermissions ¶ added in v0.5.9
func (s *PGDocStore) BulkCheckPermissions( ctx context.Context, req BulkCheckPermissionRequest, ) ([]uuid.UUID, error)
BulkCheckPermissions implements DocStore.
func (*PGDocStore) BulkGetDocuments ¶ added in v0.7.5
func (s *PGDocStore) BulkGetDocuments( ctx context.Context, documents []BulkGetReference, ) ([]BulkGetItem, error)
BulkGetDocuments implements DocStore.
func (*PGDocStore) CheckPermissions ¶ added in v0.4.6
func (s *PGDocStore) CheckPermissions( ctx context.Context, req CheckPermissionRequest, ) (CheckPermissionResult, error)
CheckPermission implements DocStore.
func (*PGDocStore) DeactivateSchema ¶
func (s *PGDocStore) DeactivateSchema( ctx context.Context, name string, ) (outErr error)
DeactivateSchema implements DocStore.
func (*PGDocStore) Delete ¶
func (s *PGDocStore) Delete( ctx context.Context, req DeleteRequest, ) (outErr error)
Delete implements DocStore.
func (*PGDocStore) DeleteDocumentWorkflow ¶ added in v0.9.0
func (s *PGDocStore) DeleteDocumentWorkflow( ctx context.Context, docType string, ) error
func (*PGDocStore) DeleteMetricKind ¶
func (s *PGDocStore) DeleteMetricKind( ctx context.Context, name string, ) error
func (*PGDocStore) DeleteStatusRule ¶
func (*PGDocStore) GetActiveSchemas ¶
func (s *PGDocStore) GetActiveSchemas( ctx context.Context, ) ([]*Schema, error)
GetActiveSchemas implements DocStore.
func (*PGDocStore) GetCompactedEventlog ¶ added in v0.4.0
func (s *PGDocStore) GetCompactedEventlog( ctx context.Context, req GetCompactedEventlogRequest, ) ([]Event, error)
func (*PGDocStore) GetDeprecations ¶ added in v0.5.1
func (s *PGDocStore) GetDeprecations( ctx context.Context, ) ([]*Deprecation, error)
GetDeprecations implements SchemaLoader.
func (*PGDocStore) GetDocument ¶
func (s *PGDocStore) GetDocument( ctx context.Context, uuid uuid.UUID, version int64, ) (*newsdoc.Document, int64, error)
GetDocument implements DocStore.
func (*PGDocStore) GetDocumentACL ¶
func (*PGDocStore) GetDocumentMeta ¶
func (s *PGDocStore) GetDocumentMeta( ctx context.Context, docID uuid.UUID, ) (*DocumentMeta, error)
GetDocumentMeta implements DocStore.
func (*PGDocStore) GetDocumentWorkflow ¶ added in v0.9.0
func (s *PGDocStore) GetDocumentWorkflow( ctx context.Context, docType string, ) (DocumentWorkflow, error)
func (*PGDocStore) GetDocumentWorkflows ¶ added in v0.9.0
func (s *PGDocStore) GetDocumentWorkflows( ctx context.Context, ) ([]DocumentWorkflow, error)
func (*PGDocStore) GetEnforcedDeprecations ¶ added in v0.5.1
func (s *PGDocStore) GetEnforcedDeprecations( ctx context.Context, ) (EnforcedDeprecations, error)
GetEnforcedDeprecations implements SchemaLoader.
func (*PGDocStore) GetEventlog ¶
func (*PGDocStore) GetLastEvent ¶ added in v0.4.0
func (s *PGDocStore) GetLastEvent( ctx context.Context, ) (*Event, error)
func (*PGDocStore) GetLastEventID ¶ added in v0.4.0
func (s *PGDocStore) GetLastEventID(ctx context.Context) (int64, error)
GetLastEventID implements DocStore.
func (*PGDocStore) GetMetaTypeForDocument ¶ added in v0.4.6
func (s *PGDocStore) GetMetaTypeForDocument( ctx context.Context, uuid uuid.UUID, ) (DocumentMetaType, error)
GetMetaTypeForDocument implements DocStore.
func (*PGDocStore) GetMetricKind ¶
func (s *PGDocStore) GetMetricKind( ctx context.Context, name string, ) (*MetricKind, error)
func (*PGDocStore) GetMetricKinds ¶
func (s *PGDocStore) GetMetricKinds( ctx context.Context, ) ([]*MetricKind, error)
func (*PGDocStore) GetSchema ¶
func (s *PGDocStore) GetSchema( ctx context.Context, name string, version string, ) (*Schema, error)
GetSchema implements DocStore.
func (*PGDocStore) GetSchemaVersions ¶
func (*PGDocStore) GetSinkPosition ¶
func (*PGDocStore) GetStatusHistory ¶
func (*PGDocStore) GetStatusOverview ¶ added in v0.5.9
func (s *PGDocStore) GetStatusOverview( ctx context.Context, uuids []uuid.UUID, statuses []string, getMeta bool, ) ([]StatusOverviewItem, error)
GetStatusOverview implements DocStore.
func (*PGDocStore) GetStatusRules ¶
func (s *PGDocStore) GetStatusRules(ctx context.Context) ([]StatusRule, error)
func (*PGDocStore) GetStatuses ¶
func (s *PGDocStore) GetStatuses(ctx context.Context) ([]DocumentStatus, error)
func (*PGDocStore) GetTypeOfDocument ¶ added in v0.8.0
GetTypeOfDocument implements DocStore.
func (*PGDocStore) GetVersion ¶
func (s *PGDocStore) GetVersion( ctx context.Context, uuid uuid.UUID, version int64, ) (DocumentUpdate, error)
func (*PGDocStore) GetVersionHistory ¶
func (s *PGDocStore) GetVersionHistory( ctx context.Context, uuid uuid.UUID, before int64, count int, ) ([]DocumentUpdate, error)
func (*PGDocStore) ListDeleteRecords ¶ added in v0.5.9
func (s *PGDocStore) ListDeleteRecords( ctx context.Context, docUUID *uuid.UUID, beforeID int64, beforeTime *time.Time, ) ([]DeleteRecord, error)
func (*PGDocStore) Lock ¶
func (s *PGDocStore) Lock(ctx context.Context, req LockRequest) (LockResult, error)
func (*PGDocStore) OnArchivedUpdate ¶
func (s *PGDocStore) OnArchivedUpdate( ctx context.Context, ch chan ArchivedEvent, )
OnSchemaUpdate notifies the channel ch of all archived status updates. Subscription is automatically cancelled once the context is cancelled.
Note that we don't provide any delivery guarantees for these events. non-blocking send is used on ch, so if it's unbuffered events will be discarded if the receiver is busy.
func (*PGDocStore) OnDeprecationUpdate ¶ added in v0.5.1
func (s *PGDocStore) OnDeprecationUpdate( ctx context.Context, ch chan DeprecationEvent, )
OnSchemaUpdate notifies the channel ch of all schema updates. Subscription is automatically cancelled once the context is cancelled.
Note that we don't provide any delivery guarantees for these events. non-blocking send is used on ch, so if it's unbuffered events will be discarded if the receiver is busy.
func (*PGDocStore) OnEventlog ¶
func (s *PGDocStore) OnEventlog( ctx context.Context, ch chan int64, )
OnEventlog notifies the channel ch of all new eventlog IDs. Subscription is automatically cancelled once the context is cancelled.
Note that we don't provide any delivery guarantees for these events. non-blocking send is used on ch, so if it's unbuffered events will be discarded if the receiver is busy.
func (*PGDocStore) OnSchemaUpdate ¶
func (s *PGDocStore) OnSchemaUpdate( ctx context.Context, ch chan SchemaEvent, )
OnSchemaUpdate notifies the channel ch of all schema updates. Subscription is automatically cancelled once the context is cancelled.
Note that we don't provide any delivery guarantees for these events. non-blocking send is used on ch, so if it's unbuffered events will be discarded if the receiver is busy.
func (*PGDocStore) OnWorkflowUpdate ¶
func (s *PGDocStore) OnWorkflowUpdate( ctx context.Context, ch chan WorkflowEvent, )
OnWorkflowUpdate notifies the channel ch of all workflow updates. Subscription is automatically cancelled once the context is cancelled.
Note that we don't provide any delivery guarantees for these events. non-blocking send is used on ch, so if it's unbuffered events will be discarded if the receiver is busy.
func (*PGDocStore) PurgeDocument ¶ added in v0.5.9
func (*PGDocStore) RegisterMetaType ¶ added in v0.4.6
func (s *PGDocStore) RegisterMetaType( ctx context.Context, metaType string, exclusive bool, ) error
RegisterMetaType implements DocStore.
func (*PGDocStore) RegisterMetaTypeUse ¶ added in v0.4.6
func (s *PGDocStore) RegisterMetaTypeUse(ctx context.Context, mainType string, metaType string) error
RegisterMetaTypeUse implements DocStore.
func (*PGDocStore) RegisterMetricKind ¶
func (s *PGDocStore) RegisterMetricKind( ctx context.Context, name string, aggregation Aggregation, ) error
func (*PGDocStore) RegisterOrIncrementMetric ¶
func (s *PGDocStore) RegisterOrIncrementMetric(ctx context.Context, metric Metric) error
RegisterMetric implements MetricStore.
func (*PGDocStore) RegisterOrReplaceMetric ¶
func (s *PGDocStore) RegisterOrReplaceMetric(ctx context.Context, metric Metric) error
RegisterMetric implements MetricStore.
func (*PGDocStore) RegisterSchema ¶
func (s *PGDocStore) RegisterSchema( ctx context.Context, req RegisterSchemaRequest, ) error
RegisterSchema implements DocStore.
func (*PGDocStore) RestoreDocument ¶ added in v0.5.9
func (*PGDocStore) RunCleaner ¶ added in v0.3.0
func (s *PGDocStore) RunCleaner(ctx context.Context, period time.Duration)
func (*PGDocStore) RunListener ¶
func (s *PGDocStore) RunListener(ctx context.Context)
RunListener opens a connection to the database and subscribes to all store notifications.
func (*PGDocStore) SetDocumentWorkflow ¶ added in v0.9.0
func (s *PGDocStore) SetDocumentWorkflow( ctx context.Context, workflow DocumentWorkflow, ) error
func (*PGDocStore) SetSinkPosition ¶
func (*PGDocStore) Update ¶
func (s *PGDocStore) Update( ctx context.Context, workflows WorkflowProvider, requests []*UpdateRequest, ) (_ []DocumentUpdate, outErr error)
Update implements DocStore.
func (*PGDocStore) UpdateDeprecation ¶ added in v0.5.1
func (s *PGDocStore) UpdateDeprecation( ctx context.Context, deprecation Deprecation, ) error
UpdateDeprecation implements SchemaLoader.
func (*PGDocStore) UpdateLock ¶
func (s *PGDocStore) UpdateLock(ctx context.Context, req UpdateLockRequest) (LockResult, error)
func (*PGDocStore) UpdatePreflight ¶ added in v0.5.9
func (s *PGDocStore) UpdatePreflight( ctx context.Context, q *postgres.Queries, docUUID uuid.UUID, ifMatch int64, ) (*UpdatePrefligthInfo, error)
func (*PGDocStore) UpdateStatus ¶
func (s *PGDocStore) UpdateStatus( ctx context.Context, req UpdateStatusRequest, ) error
func (*PGDocStore) UpdateStatusRule ¶
func (s *PGDocStore) UpdateStatusRule( ctx context.Context, rule StatusRule, ) error
type PGDocStoreOptions ¶
type PGReplication ¶
type PGReplication struct {
// contains filtered or unexported fields
}
func NewPGReplication ¶
func NewPGReplication( logger *slog.Logger, pool *pgxpool.Pool, dbURI string, slotName string, metricsRegisterer prometheus.Registerer, ) (*PGReplication, error)
func (*PGReplication) Run ¶
func (pr *PGReplication) Run(ctx context.Context)
func (*PGReplication) Started ¶
func (pr *PGReplication) Started() <-chan bool
Started emits true as a signal every time replication has started.
func (*PGReplication) Stop ¶
func (pr *PGReplication) Stop()
type Permission ¶
type Permission string
const ( ReadPermission Permission = "r" WritePermission Permission = "w" MetaWritePermission Permission = "m" SetStatusPermission Permission = "s" )
func (Permission) Name ¶
func (p Permission) Name() string
type RegisterSchemaRequest ¶
type RegisterSchemaRequest struct { Name string Version string Specification revisor.ConstraintSet Activate bool }
type RestoreSpec ¶ added in v0.5.9
type RestoreSpec struct {
ACL []ACLEntry
}
type RouterOption ¶
type RouterOption func(router *httprouter.Router) error
func WithDocumentsAPI ¶
func WithDocumentsAPI( service repository.Documents, opts ServerOptions, ) RouterOption
func WithMetricsAPI ¶
func WithMetricsAPI( service repository.Metrics, opts ServerOptions, ) RouterOption
func WithReportsAPI ¶
func WithReportsAPI( service repository.Reports, opts ServerOptions, ) RouterOption
func WithSSE ¶ added in v0.4.4
func WithSSE( handler http.Handler, opt ServerOptions, ) RouterOption
func WithSchemasAPI ¶
func WithSchemasAPI( service repository.Schemas, opts ServerOptions, ) RouterOption
func WithWorkflowsAPI ¶
func WithWorkflowsAPI( service repository.Workflows, opts ServerOptions, ) RouterOption
type SSE ¶ added in v0.4.4
type SSE struct {
// contains filtered or unexported fields
}
func (*SSE) HTTPHandler ¶ added in v0.4.4
type SchemaEvent ¶
type SchemaEvent struct { Type SchemaEventType `json:"type"` Name string `json:"name"` }
type SchemaEventType ¶
type SchemaEventType int
const ( SchemaEventTypeActivation SchemaEventType = iota SchemaEventTypeDeactivation )
type SchemaStore ¶
type SchemaStore interface { RegisterSchema( ctx context.Context, req RegisterSchemaRequest, ) error ActivateSchema( ctx context.Context, name, version string, ) error DeactivateSchema( ctx context.Context, name string, ) error GetSchema( ctx context.Context, name, version string, ) (*Schema, error) GetActiveSchemas(ctx context.Context) ([]*Schema, error) GetSchemaVersions(ctx context.Context) (map[string]string, error) OnSchemaUpdate(ctx context.Context, ch chan SchemaEvent) RegisterMetaType( ctx context.Context, metaType string, exclusive bool, ) error RegisterMetaTypeUse( ctx context.Context, mainType string, metaType string, ) error GetDeprecations( ctx context.Context, ) ([]*Deprecation, error) UpdateDeprecation( ctx context.Context, deprecation Deprecation, ) error }
type SchemasService ¶
type SchemasService struct {
// contains filtered or unexported fields
}
func NewSchemasService ¶
func NewSchemasService(logger *slog.Logger, store SchemaStore) *SchemasService
func (*SchemasService) Get ¶
func (a *SchemasService) Get( ctx context.Context, req *repository.GetSchemaRequest, ) (*repository.GetSchemaResponse, error)
Get retrieves a schema.
func (*SchemasService) GetAllActive ¶
func (a *SchemasService) GetAllActive( ctx context.Context, req *repository.GetAllActiveSchemasRequest, ) (*repository.GetAllActiveSchemasResponse, error)
GetAllActiveSchemas returns the currently active schemas.
func (*SchemasService) GetDeprecations ¶ added in v0.5.1
func (a *SchemasService) GetDeprecations( ctx context.Context, _ *repository.GetDeprecationsRequest, ) (*repository.GetDeprecationsResponse, error)
GetDeprecations implements repository.Schemas.
func (*SchemasService) Register ¶
func (a *SchemasService) Register( ctx context.Context, req *repository.RegisterSchemaRequest, ) (*repository.RegisterSchemaResponse, error)
Register register a new validation schema version.
func (*SchemasService) RegisterMetaType ¶ added in v0.4.6
func (a *SchemasService) RegisterMetaType( ctx context.Context, req *repository.RegisterMetaTypeRequest, ) (*repository.RegisterMetaTypeResponse, error)
RegisterMetaType implements repository.Schemas.
func (*SchemasService) RegisterMetaTypeUse ¶ added in v0.4.6
func (a *SchemasService) RegisterMetaTypeUse( ctx context.Context, req *repository.RegisterMetaTypeUseRequest, ) (*repository.RegisterMetaTypeUseResponse, error)
RegisterMetaTypeUse implements repository.Schemas.
func (*SchemasService) SetActive ¶
func (a *SchemasService) SetActive( ctx context.Context, req *repository.SetActiveSchemaRequest, ) (*repository.SetActiveSchemaResponse, error)
SetActive activates schema versions.
func (*SchemasService) UpdateDeprecation ¶ added in v0.5.1
func (a *SchemasService) UpdateDeprecation( ctx context.Context, req *repository.UpdateDeprecationRequest, ) (*repository.UpdateDeprecationResponse, error)
UpdateDeprecation implements repository.Schemas.
type ServerOptions ¶
type ServerOptions struct { Hooks *twirp.ServerHooks AuthMiddleware func( w http.ResponseWriter, r *http.Request, next http.Handler, ) error }
func (*ServerOptions) SetJWTValidation ¶
func (so *ServerOptions) SetJWTValidation(parser elephantine.AuthInfoParser)
type SigningKey ¶
type SigningKeySet ¶
type SigningKeySet struct { Keys []SigningKey `json:"keys"` // contains filtered or unexported fields }
func (*SigningKeySet) CurrentKey ¶
func (s *SigningKeySet) CurrentKey(t time.Time) *SigningKey
func (*SigningKeySet) GetKeyByID ¶
func (s *SigningKeySet) GetKeyByID(kid string) *SigningKey
func (*SigningKeySet) LatestKey ¶
func (s *SigningKeySet) LatestKey() *SigningKey
func (*SigningKeySet) Replace ¶
func (s *SigningKeySet) Replace(keys []SigningKey)
type StatusOverviewItem ¶ added in v0.5.9
type StatusRule ¶
type StatusRuleError ¶
type StatusRuleError struct {
Violations []StatusRuleViolation
}
func (StatusRuleError) Error ¶
func (err StatusRuleError) Error() string
type StatusRuleInput ¶
type StatusRuleViolation ¶
type StatusUpdate ¶
func RPCToStatusUpdate ¶
func RPCToStatusUpdate(update []*repository.StatusUpdate) []StatusUpdate
type SystemState ¶ added in v0.5.9
type SystemState string
type TokenResponse ¶
type TupleDecoder ¶
type TupleDecoder struct {
// contains filtered or unexported fields
}
func NewTupleDecoder ¶
func NewTupleDecoder() *TupleDecoder
func (*TupleDecoder) DecodeValues ¶
func (td *TupleDecoder) DecodeValues( relation uint32, tuple *pglogrepl.TupleData, ) (*pglogrepl.RelationMessage, map[string]interface{}, error)
func (*TupleDecoder) GetRelation ¶
func (td *TupleDecoder) GetRelation(id uint32) (*pglogrepl.RelationMessage, bool)
func (*TupleDecoder) RegisterRelation ¶
func (td *TupleDecoder) RegisterRelation(rel *pglogrepl.RelationMessage)
type UpdatePrefligthInfo ¶ added in v0.5.9
type UpdateRequest ¶
type UpdateStatusRequest ¶
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func NewValidator ¶
func NewValidator( ctx context.Context, logger *slog.Logger, loader ValidatorStore, metricsRegisterer prometheus.Registerer, ) (*Validator, error)
func (*Validator) GetValidator ¶
func (*Validator) ValidateDocument ¶
type ValidatorStore ¶ added in v0.5.1
type ValidatorStore interface { GetActiveSchemas(ctx context.Context) ([]*Schema, error) OnSchemaUpdate(ctx context.Context, ch chan SchemaEvent) GetEnforcedDeprecations(ctx context.Context) (EnforcedDeprecations, error) OnDeprecationUpdate(ctx context.Context, ch chan DeprecationEvent) }
type WorkflowEvent ¶
type WorkflowEvent struct { Type WorkflowEventType `json:"type"` DocType string `json:"doc_type"` Name string `json:"name"` }
type WorkflowEventType ¶
type WorkflowEventType int
const ( WorkflowEventTypeStatusChange WorkflowEventType = iota WorkflowEventTypeStatusRuleChange WorkflowEventTypeWorkflowChange )
type WorkflowLoader ¶
type WorkflowLoader interface { GetStatuses(ctx context.Context) ([]DocumentStatus, error) GetStatusRules(ctx context.Context) ([]StatusRule, error) SetDocumentWorkflow(ctx context.Context, workflow DocumentWorkflow) error GetDocumentWorkflows(ctx context.Context) ([]DocumentWorkflow, error) GetDocumentWorkflow(ctx context.Context, docType string) (DocumentWorkflow, error) DeleteDocumentWorkflow(ctx context.Context, docType string) error OnWorkflowUpdate(ctx context.Context, ch chan WorkflowEvent) }
type WorkflowProvider ¶
type WorkflowProvider interface { HasStatus(docType string, name string) bool EvaluateRules(input StatusRuleInput) []StatusRuleViolation GetDocumentWorkflow(docType string) (DocumentWorkflow, bool) }
type WorkflowState ¶ added in v0.9.0
func (WorkflowState) Equal ¶ added in v0.9.0
func (ws WorkflowState) Equal(b WorkflowState) bool
type WorkflowStep ¶ added in v0.9.0
type WorkflowStep struct { // Version should be set if this is a document version bump. Version int64 // Status should be set if this is a status update. Status *StatusUpdate }
type WorkflowStore ¶
type WorkflowStore interface { UpdateStatus( ctx context.Context, req UpdateStatusRequest, ) error GetStatuses(ctx context.Context) ([]DocumentStatus, error) UpdateStatusRule( ctx context.Context, rule StatusRule, ) error DeleteStatusRule( ctx context.Context, docType string, name string, ) error GetStatusRules(ctx context.Context) ([]StatusRule, error) SetDocumentWorkflow(ctx context.Context, workflow DocumentWorkflow) error GetDocumentWorkflows(ctx context.Context) ([]DocumentWorkflow, error) GetDocumentWorkflow(ctx context.Context, docType string) (DocumentWorkflow, error) DeleteDocumentWorkflow(ctx context.Context, docType string) error }
type Workflows ¶
type Workflows struct {
// contains filtered or unexported fields
}
func NewWorkflows ¶
func (*Workflows) EvaluateRules ¶
func (w *Workflows) EvaluateRules( input StatusRuleInput, ) []StatusRuleViolation
func (*Workflows) GetDocumentWorkflow ¶ added in v0.9.0
func (w *Workflows) GetDocumentWorkflow(docType string) (DocumentWorkflow, bool)
type WorkflowsService ¶
type WorkflowsService struct {
// contains filtered or unexported fields
}
func NewWorkflowsService ¶
func NewWorkflowsService(store WorkflowStore) *WorkflowsService
func (*WorkflowsService) CreateStatusRule ¶
func (s *WorkflowsService) CreateStatusRule( ctx context.Context, req *repository.CreateStatusRuleRequest, ) (*repository.CreateStatusRuleResponse, error)
CreateStatusRule creates or updates a status rule that should be applied when setting statuses.
func (*WorkflowsService) DeleteStatusRule ¶
func (s *WorkflowsService) DeleteStatusRule( ctx context.Context, req *repository.DeleteStatusRuleRequest, ) (*repository.DeleteStatusRuleResponse, error)
DeleteStatusRule removes a status rule.
func (*WorkflowsService) DeleteWorkflow ¶ added in v0.9.0
func (s *WorkflowsService) DeleteWorkflow( ctx context.Context, req *repository.DeleteWorkflowRequest, ) (*repository.DeleteWorkflowResponse, error)
DeleteWorkflow implements repository.Workflows.
func (*WorkflowsService) GetStatusRules ¶
func (s *WorkflowsService) GetStatusRules( ctx context.Context, _ *repository.GetStatusRulesRequest, ) (*repository.GetStatusRulesResponse, error)
GetStatusRules returns all status rules.
func (*WorkflowsService) GetStatuses ¶
func (s *WorkflowsService) GetStatuses( ctx context.Context, _ *repository.GetStatusesRequest, ) (*repository.GetStatusesResponse, error)
GetStatuses lists all enabled statuses.
func (*WorkflowsService) GetWorkflow ¶ added in v0.9.0
func (s *WorkflowsService) GetWorkflow( ctx context.Context, req *repository.GetWorkflowRequest, ) (*repository.GetWorkflowResponse, error)
GetWorkflow implements repository.Workflows.
func (*WorkflowsService) SetWorkflow ¶ added in v0.9.0
func (s *WorkflowsService) SetWorkflow( ctx context.Context, req *repository.SetWorkflowRequest, ) (*repository.SetWorkflowResponse, error)
SetWorkflow implements repository.Workflows.
func (*WorkflowsService) UpdateStatus ¶
func (s *WorkflowsService) UpdateStatus( ctx context.Context, req *repository.UpdateStatusRequest, ) (*repository.UpdateStatusResponse, error)
UpdateStatus creates or updates a status that can be used for documents.