Custom Backends

Create custom data backends for qqq

Overview

Backends in qqq provide data storage and retrieval. While qqq includes backends for RDBMS, MongoDB, and more, you can create custom backends for specialized needs.

Backend Interface

Implement the QBackendModule interface:

Java
public class MyCustomBackend implements QBackendModule {
    @Override
    public String getName() {
        return "my-custom-backend";
    }
    
    @Override
    public QueryOutput executeQuery(QueryInput input) {
        // Implement query logic
    }
    
    @Override
    public InsertOutput executeInsert(InsertInput input) {
        // Implement insert logic
    }
    
    @Override
    public UpdateOutput executeUpdate(UpdateInput input) {
        // Implement update logic
    }
    
    @Override
    public DeleteOutput executeDelete(DeleteInput input) {
        // Implement delete logic
    }
}

Registration

Register your backend in the QInstance:

Java
qInstance.addBackend(new QBackendMetaData()
    .withName("myBackend")
    .withBackendType("my-custom-backend")
    .withSettings(Map.of(
        "connectionString", "custom://localhost:1234"
    )));

Use Cases

Custom backends are useful for:

  • Legacy system integration
  • Specialized databases
  • External API wrappers
  • File-based storage
  • In-memory testing
  • Best Practices

  • Handle connection pooling appropriately
  • Implement proper error handling
  • Support transactions where possible
  • Add logging for debugging
  • Next Steps

  • Custom Actions - Extend action system
  • Creating qBits - Package as qBit
  • Powered by qqq