feat(epic1): implement core infrastructure (stories 1.1-1.5)
Implemented Epic 1 core kernel and infrastructure stories: Story 1.1: Enhanced DI Container - Added providers for database, health, metrics, and error bus - Extended CoreModule to include all core services Story 1.2: Database Layer with Ent ORM - Created Ent schema for User, Role, Permission, AuditLog entities - Implemented many-to-many relationships (User-Role, Role-Permission) - Created database client wrapper with connection pooling - Added database provider to DI container with migration support Story 1.3: Health Monitoring and Metrics System - Implemented health check registry and interface - Added database health checker - Created Prometheus metrics system with HTTP instrumentation - Added health and metrics providers to DI container Story 1.4: Error Handling and Error Bus - Implemented channel-based error bus - Created ErrorPublisher interface - Added error bus provider with lifecycle management Story 1.5: HTTP Server Foundation - Created HTTP server with Gin framework - Implemented comprehensive middleware stack: - Request ID generation - Structured logging - Panic recovery with error bus integration - Prometheus metrics collection - CORS support - Registered core routes: /healthz, /ready, /metrics - Integrated with FX lifecycle for graceful shutdown All components are integrated via DI container and ready for use.
This commit is contained in:
85
internal/ent/auditlog/auditlog.go
Normal file
85
internal/ent/auditlog/auditlog.go
Normal file
@@ -0,0 +1,85 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package auditlog
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the auditlog type in the database.
|
||||
Label = "audit_log"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldActorID holds the string denoting the actor_id field in the database.
|
||||
FieldActorID = "actor_id"
|
||||
// FieldAction holds the string denoting the action field in the database.
|
||||
FieldAction = "action"
|
||||
// FieldTargetID holds the string denoting the target_id field in the database.
|
||||
FieldTargetID = "target_id"
|
||||
// FieldMetadata holds the string denoting the metadata field in the database.
|
||||
FieldMetadata = "metadata"
|
||||
// FieldTimestamp holds the string denoting the timestamp field in the database.
|
||||
FieldTimestamp = "timestamp"
|
||||
// Table holds the table name of the auditlog in the database.
|
||||
Table = "audit_logs"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for auditlog fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldActorID,
|
||||
FieldAction,
|
||||
FieldTargetID,
|
||||
FieldMetadata,
|
||||
FieldTimestamp,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// ActorIDValidator is a validator for the "actor_id" field. It is called by the builders before save.
|
||||
ActorIDValidator func(string) error
|
||||
// ActionValidator is a validator for the "action" field. It is called by the builders before save.
|
||||
ActionValidator func(string) error
|
||||
// DefaultTimestamp holds the default value on creation for the "timestamp" field.
|
||||
DefaultTimestamp func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the AuditLog queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByActorID orders the results by the actor_id field.
|
||||
func ByActorID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldActorID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAction orders the results by the action field.
|
||||
func ByAction(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAction, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTargetID orders the results by the target_id field.
|
||||
func ByTargetID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTargetID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTimestamp orders the results by the timestamp field.
|
||||
func ByTimestamp(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTimestamp, opts...).ToFunc()
|
||||
}
|
||||
355
internal/ent/auditlog/where.go
Normal file
355
internal/ent/auditlog/where.go
Normal file
@@ -0,0 +1,355 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package auditlog
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"git.dcentral.systems/toolz/goplt/internal/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEqualFold applies the EqualFold predicate on the ID field.
|
||||
func IDEqualFold(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldID, id))
|
||||
}
|
||||
|
||||
// IDContainsFold applies the ContainsFold predicate on the ID field.
|
||||
func IDContainsFold(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldID, id))
|
||||
}
|
||||
|
||||
// ActorID applies equality check predicate on the "actor_id" field. It's identical to ActorIDEQ.
|
||||
func ActorID(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldActorID, v))
|
||||
}
|
||||
|
||||
// Action applies equality check predicate on the "action" field. It's identical to ActionEQ.
|
||||
func Action(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldAction, v))
|
||||
}
|
||||
|
||||
// TargetID applies equality check predicate on the "target_id" field. It's identical to TargetIDEQ.
|
||||
func TargetID(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// Timestamp applies equality check predicate on the "timestamp" field. It's identical to TimestampEQ.
|
||||
func Timestamp(v time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldTimestamp, v))
|
||||
}
|
||||
|
||||
// ActorIDEQ applies the EQ predicate on the "actor_id" field.
|
||||
func ActorIDEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDNEQ applies the NEQ predicate on the "actor_id" field.
|
||||
func ActorIDNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDIn applies the In predicate on the "actor_id" field.
|
||||
func ActorIDIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldActorID, vs...))
|
||||
}
|
||||
|
||||
// ActorIDNotIn applies the NotIn predicate on the "actor_id" field.
|
||||
func ActorIDNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldActorID, vs...))
|
||||
}
|
||||
|
||||
// ActorIDGT applies the GT predicate on the "actor_id" field.
|
||||
func ActorIDGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDGTE applies the GTE predicate on the "actor_id" field.
|
||||
func ActorIDGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDLT applies the LT predicate on the "actor_id" field.
|
||||
func ActorIDLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDLTE applies the LTE predicate on the "actor_id" field.
|
||||
func ActorIDLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDContains applies the Contains predicate on the "actor_id" field.
|
||||
func ActorIDContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDHasPrefix applies the HasPrefix predicate on the "actor_id" field.
|
||||
func ActorIDHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDHasSuffix applies the HasSuffix predicate on the "actor_id" field.
|
||||
func ActorIDHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDEqualFold applies the EqualFold predicate on the "actor_id" field.
|
||||
func ActorIDEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActorIDContainsFold applies the ContainsFold predicate on the "actor_id" field.
|
||||
func ActorIDContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldActorID, v))
|
||||
}
|
||||
|
||||
// ActionEQ applies the EQ predicate on the "action" field.
|
||||
func ActionEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionNEQ applies the NEQ predicate on the "action" field.
|
||||
func ActionNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionIn applies the In predicate on the "action" field.
|
||||
func ActionIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldAction, vs...))
|
||||
}
|
||||
|
||||
// ActionNotIn applies the NotIn predicate on the "action" field.
|
||||
func ActionNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldAction, vs...))
|
||||
}
|
||||
|
||||
// ActionGT applies the GT predicate on the "action" field.
|
||||
func ActionGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionGTE applies the GTE predicate on the "action" field.
|
||||
func ActionGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionLT applies the LT predicate on the "action" field.
|
||||
func ActionLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionLTE applies the LTE predicate on the "action" field.
|
||||
func ActionLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionContains applies the Contains predicate on the "action" field.
|
||||
func ActionContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionHasPrefix applies the HasPrefix predicate on the "action" field.
|
||||
func ActionHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionHasSuffix applies the HasSuffix predicate on the "action" field.
|
||||
func ActionHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionEqualFold applies the EqualFold predicate on the "action" field.
|
||||
func ActionEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldAction, v))
|
||||
}
|
||||
|
||||
// ActionContainsFold applies the ContainsFold predicate on the "action" field.
|
||||
func ActionContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldAction, v))
|
||||
}
|
||||
|
||||
// TargetIDEQ applies the EQ predicate on the "target_id" field.
|
||||
func TargetIDEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDNEQ applies the NEQ predicate on the "target_id" field.
|
||||
func TargetIDNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDIn applies the In predicate on the "target_id" field.
|
||||
func TargetIDIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldTargetID, vs...))
|
||||
}
|
||||
|
||||
// TargetIDNotIn applies the NotIn predicate on the "target_id" field.
|
||||
func TargetIDNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldTargetID, vs...))
|
||||
}
|
||||
|
||||
// TargetIDGT applies the GT predicate on the "target_id" field.
|
||||
func TargetIDGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDGTE applies the GTE predicate on the "target_id" field.
|
||||
func TargetIDGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDLT applies the LT predicate on the "target_id" field.
|
||||
func TargetIDLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDLTE applies the LTE predicate on the "target_id" field.
|
||||
func TargetIDLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDContains applies the Contains predicate on the "target_id" field.
|
||||
func TargetIDContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDHasPrefix applies the HasPrefix predicate on the "target_id" field.
|
||||
func TargetIDHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDHasSuffix applies the HasSuffix predicate on the "target_id" field.
|
||||
func TargetIDHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDIsNil applies the IsNil predicate on the "target_id" field.
|
||||
func TargetIDIsNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIsNull(FieldTargetID))
|
||||
}
|
||||
|
||||
// TargetIDNotNil applies the NotNil predicate on the "target_id" field.
|
||||
func TargetIDNotNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotNull(FieldTargetID))
|
||||
}
|
||||
|
||||
// TargetIDEqualFold applies the EqualFold predicate on the "target_id" field.
|
||||
func TargetIDEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// TargetIDContainsFold applies the ContainsFold predicate on the "target_id" field.
|
||||
func TargetIDContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldTargetID, v))
|
||||
}
|
||||
|
||||
// MetadataIsNil applies the IsNil predicate on the "metadata" field.
|
||||
func MetadataIsNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIsNull(FieldMetadata))
|
||||
}
|
||||
|
||||
// MetadataNotNil applies the NotNil predicate on the "metadata" field.
|
||||
func MetadataNotNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotNull(FieldMetadata))
|
||||
}
|
||||
|
||||
// TimestampEQ applies the EQ predicate on the "timestamp" field.
|
||||
func TimestampEQ(v time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldTimestamp, v))
|
||||
}
|
||||
|
||||
// TimestampNEQ applies the NEQ predicate on the "timestamp" field.
|
||||
func TimestampNEQ(v time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldTimestamp, v))
|
||||
}
|
||||
|
||||
// TimestampIn applies the In predicate on the "timestamp" field.
|
||||
func TimestampIn(vs ...time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldTimestamp, vs...))
|
||||
}
|
||||
|
||||
// TimestampNotIn applies the NotIn predicate on the "timestamp" field.
|
||||
func TimestampNotIn(vs ...time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldTimestamp, vs...))
|
||||
}
|
||||
|
||||
// TimestampGT applies the GT predicate on the "timestamp" field.
|
||||
func TimestampGT(v time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldTimestamp, v))
|
||||
}
|
||||
|
||||
// TimestampGTE applies the GTE predicate on the "timestamp" field.
|
||||
func TimestampGTE(v time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldTimestamp, v))
|
||||
}
|
||||
|
||||
// TimestampLT applies the LT predicate on the "timestamp" field.
|
||||
func TimestampLT(v time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldTimestamp, v))
|
||||
}
|
||||
|
||||
// TimestampLTE applies the LTE predicate on the "timestamp" field.
|
||||
func TimestampLTE(v time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldTimestamp, v))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.AuditLog) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.AuditLog) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.AuditLog) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.NotPredicates(p))
|
||||
}
|
||||
Reference in New Issue
Block a user