Timescale Db

Description

TimescaleDB (PostgreSQL extension) can be used as the backing implementation for Flex time-series operations. Your application code should depend on IFlexTimeSeriesStore, while Flex provides the provider bridge and wiring.

Important concepts

  • IFlexTimeSeriesStore is the contract: app code writes and queries time-series data via a shared interface.

  • PostgreSQL connection + schema: TimescaleDB is accessed through a Postgres connection string and optional schema.

  • Provider bridge: the TimescaleDB implementation is exposed via an IFlexTimeSeriesStoreBridge internally, but most consumers only need IFlexTimeSeriesStore.

Configuration in DI

Add the provider in your DI composition root (commonly in EndPoints/...CommonConfigs/OtherApplicationServicesConfig.cs or wherever you centralize registrations).

// using Sumeru.Flex; // IFlexTimeSeriesStore

public static class OtherApplicationServicesConfig
{
	public static IServiceCollection AddOtherApplicationServices(
		this IServiceCollection services,
		IConfiguration configuration)
	{
		// Registers TimescaleDB as the IFlexTimeSeriesStore bridge.
		// Flex auto-wires generated Queries/Handlers that *use* IFlexTimeSeriesStore.
		services.AddFlexTimescaleDBTimeSeriesStore(configuration);

		return services;
	}
}

appsettings.json

Configuration is read from FlexBase:DataStores:TimeSeries:TimescaleDB.

Examples (template-based)

These examples mirror the generated Query and PostBusHandler templates. You do not register these types manually—Flex discovers and wires generated Queries/Handlers automatically.

Get the latest point (Query)

TimescaleDB considerations

  • Make sure the TimescaleDB extension is installed/enabled in your Postgres instance.

  • Store ConnectionString securely (Key Vault / secret provider).

Last updated