feature/microservice-architecture #5

Merged
master merged 15 commits from feature/microservice-architecture into main 2025-11-06 13:47:18 +01:00
2 changed files with 27 additions and 24 deletions
Showing only changes of commit 767654f257 - Show all commits

View File

@@ -50,26 +50,27 @@ func (c *AuthClient) Logout(ctx context.Context, refreshToken string) error {
return fmt.Errorf("not implemented: proto files not yet generated")
}
// connectToService discovers and connects to a service instance.
func connectToService(ctx context.Context, reg registry.ServiceRegistry, serviceName string) (*grpc.ClientConn, error) {
instances, err := reg.Discover(ctx, serviceName)
if err != nil {
return nil, fmt.Errorf("failed to discover service %s: %w", serviceName, err)
}
if len(instances) == 0 {
return nil, fmt.Errorf("no instances found for service %s", serviceName)
}
// Use the first healthy instance (load balancing can be added later)
instance := instances[0]
address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
// Create gRPC connection
conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("failed to connect to %s at %s: %w", serviceName, address, err)
}
return conn, nil
}
// TODO: connectToService will be implemented when proto files are generated
// This function will discover and connect to a service instance via gRPC.
// func connectToService(ctx context.Context, reg registry.ServiceRegistry, serviceName string) (*grpc.ClientConn, error) {
// instances, err := reg.Discover(ctx, serviceName)
// if err != nil {
// return nil, fmt.Errorf("failed to discover service %s: %w", serviceName, err)
// }
//
// if len(instances) == 0 {
// return nil, fmt.Errorf("no instances found for service %s", serviceName)
// }
//
// // Use the first healthy instance (load balancing can be added later)
// instance := instances[0]
// address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
//
// // Create gRPC connection
// conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
// if err != nil {
// return nil, fmt.Errorf("failed to connect to %s at %s: %w", serviceName, address, err)
// }
//
// return conn, nil
// }

View File

@@ -97,7 +97,9 @@ func createSchemaIfNotExists(ctx context.Context, db *sql.DB, schemaName string)
if err != nil {
return err
}
defer tx.Rollback()
defer func() {
_ = tx.Rollback() // Ignore error - if commit succeeded, rollback will error (expected)
}()
// Check if schema exists
var exists bool