Configuring qBits

Configure qBits using environment variables, YAML files, or programmatic configuration.

Configuration Methods

qBits support multiple configuration methods, allowing you to choose the approach that best fits your deployment strategy.

Environment Variables

Best for containerized deployments and secrets management.

YAML Configuration

Best for complex configurations with multiple options.

Programmatic

Best for dynamic configuration based on runtime conditions.

Environment Variables

Each qBit defines environment variables with a consistent naming convention:

Bash
# Pattern: QBIT_<NAME>_<SETTING>
QBIT_AUTH_JWT_SECRET=your-secret-key
QBIT_AUTH_JWT_EXPIRY=3600
QBIT_AUTH_JWT_ISSUER=your-app

# Database qBits
QBIT_POSTGRES_HOST=localhost
QBIT_POSTGRES_PORT=5432
QBIT_POSTGRES_DATABASE=myapp
QBIT_POSTGRES_USERNAME=user
QBIT_POSTGRES_PASSWORD=secret

YAML Configuration

For more complex configurations, use a YAML file in your project'sconfig/directory:

YAML
# config/qbits.yaml
qbits:
  auth-jwt:
    secret: ${QBIT_AUTH_JWT_SECRET}
    expiry: 3600
    issuer: your-app
    algorithms:
      - RS256
      - HS256

  postgres:
    host: ${QBIT_POSTGRES_HOST:localhost}
    port: ${QBIT_POSTGRES_PORT:5432}
    database: myapp
    pool:
      minSize: 5
      maxSize: 20

Programmatic Configuration

Configure qBits in Java when you need dynamic or conditional settings:

Java
QInstance qInstance = new QInstance();

// Configure JWT authentication
qInstance.addQBit(new AuthJwtQBit()
    .withSecret(System.getenv("JWT_SECRET"))
    .withExpiry(Duration.ofHours(1))
    .withIssuer("your-app"));

// Configure with conditional logic
if (isProduction()) {
    qInstance.addQBit(new PostgresQBit()
        .withHost(productionHost)
        .withPoolSize(20));
}

Viewing Current Configuration

Bash
# Show configuration for a qBit
qctl qbit config auth-jwt

# Show all qBit configurations
qctl qbit config --all

Next Steps

Powered by qqq