Skip to content

Configuration reference

The repository is the only component with construction-time options. NewAPI and the Services take a logger and the upstream dependency positionally; everything tunable lives on the repository.

repository.NewBaseAuditLogRepository[Payload](l, persistor, opts ...Option)

Required parameters

ParameterTypePurpose
l*zap.LoggerLogger handed to the repository.
persistor*keelmongo.PersistorMongoDB persistor that owns the connection and collection factory.

Options

OptionDefaultPurpose
WithRetention(d time.Duration)180 * 24hHow long entries are kept before the MongoDB TTL index removes them. Baked into the TTL index — see Retention.
WithCollectionName(name string)auditlogOverrides the MongoDB collection name.

Indexes created

NewBaseAuditLogRepository configures the collection with:

  • a TTL index over ttlTime (expireAfterSeconds from WithRetention);
  • a unique index over id;
  • compound indexes matching the Search filter axes:
    • { service: 1, func: 1, timestamp: -1 }
    • { userId: 1, timestamp: -1 }
    • { entityId: 1, timestamp: -1 }

auditlog.NewAPI[Payload](l, repo, opts ...Option[Payload])

ParameterTypePurpose
l*zap.LoggerLogger. Returns an error if nil.
repoAuditLogRepository[Payload]Persistence backend. Returns an error if nil.
optsOption[Payload]Functional options. None ship in v1 — the type exists for forward compatibility.

NewAPI applies no middleware. Layer telemetry / event publishing / capability checks via the command and query middleware composers.

public.NewService / private.NewService

ParameterTypePurpose
l*zap.LoggerLogger.
api*auditlog.API[Payload]The shared API instance. One API can back both Services.
optsOption[Payload]Functional options for the Service.

The filter object accepted by API.Search. All fields are optional; empty / zero values are skipped.

FieldTypeEffect
ServicestringExact match on service.
FuncstringExact match on func.
ActionstringExact match on action.
UserIDstringExact match on userId.
EntityIDstringExact match on entityId.
Fromtime.Timetimestamp >= From.
Totime.Timetimestamp <= To.
Pageint1-based page; defaults to 1 when < 1.
PageSizeintPage size; defaults to 20 when < 1.
SortSortSort field + direction; defaults to timestamp.

Released under the MIT License.