refactor: Align Epic 0 & Epic 1 with true microservices architecture
Refactor core kernel and infrastructure to support true microservices architecture where services are independently deployable. Phase 1: Core Kernel Cleanup - Remove database provider from CoreModule (services create their own) - Update ProvideHealthRegistry to not depend on database - Add schema support to database client (NewClientWithSchema) - Update main entry point to remove database dependency - Core kernel now provides only: config, logger, error bus, health, metrics, tracer, service registry Phase 2: Service Registry Implementation - Create ServiceRegistry interface (pkg/registry/registry.go) - Implement Consul registry (internal/registry/consul/consul.go) - Add Consul dependency (github.com/hashicorp/consul/api) - Add registry configuration to config/default.yaml - Add ProvideServiceRegistry() to DI container Phase 3: Service Client Interfaces - Create service client interfaces: - pkg/services/auth.go - AuthServiceClient - pkg/services/identity.go - IdentityServiceClient - pkg/services/authz.go - AuthzServiceClient - pkg/services/audit.go - AuditServiceClient - Create ServiceClientFactory (internal/client/factory.go) - Create stub gRPC client implementations (internal/client/grpc/) - Add ProvideServiceClientFactory() to DI container Phase 4: gRPC Service Definitions - Create proto files for all core services: - api/proto/auth.proto - api/proto/identity.proto - api/proto/authz.proto - api/proto/audit.proto - Add generate-proto target to Makefile Phase 5: API Gateway Implementation - Create API Gateway service entry point (cmd/api-gateway/main.go) - Create Gateway implementation (services/gateway/gateway.go) - Add gateway configuration to config/default.yaml - Gateway registers with Consul and routes requests to backend services All code compiles successfully. Core services (Auth, Identity, Authz, Audit) will be implemented in Epic 2 using these foundations.
This commit is contained in:
@@ -7,23 +7,28 @@ import (
|
||||
"os"
|
||||
|
||||
"git.dcentral.systems/toolz/goplt/internal/di"
|
||||
"git.dcentral.systems/toolz/goplt/internal/infra/database"
|
||||
"git.dcentral.systems/toolz/goplt/internal/server"
|
||||
"git.dcentral.systems/toolz/goplt/internal/health"
|
||||
"git.dcentral.systems/toolz/goplt/internal/metrics"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/config"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/logger"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create DI container with lifecycle hooks
|
||||
// We need to invoke the HTTP server to ensure all providers execute
|
||||
// This is a minimal entry point for testing core kernel infrastructure
|
||||
// Services will have their own entry points (cmd/{service}/main.go)
|
||||
container := di.NewContainer(
|
||||
// Invoke lifecycle hooks
|
||||
fx.Invoke(di.RegisterLifecycleHooks),
|
||||
// Force HTTP server to be created (which triggers all dependencies)
|
||||
// This ensures database, health, metrics, etc. are all created
|
||||
fx.Invoke(func(_ *server.Server, _ *database.Client) {
|
||||
// Both server and database are created, hooks are registered
|
||||
// This ensures all providers execute
|
||||
// Verify core kernel services are available
|
||||
fx.Invoke(func(
|
||||
_ config.ConfigProvider,
|
||||
_ logger.Logger,
|
||||
_ *health.Registry,
|
||||
_ *metrics.Metrics,
|
||||
) {
|
||||
// Core kernel services are available
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user