Klok Common

klok-common (dev.klok.framework:klok-common) is the small, dependency free library that holds the things every part of the Klok platform must spell exactly the same and therefore may only define once. The Java broker client, the Quarkus extension and the Klok Gradle plugin depend on it, and every integration gets it through the extension. Clients and tools written in other languages, the TypeScript and Python broker clients and klok.dev, carry a copy of its wire contract instead. It holds:

  • Naming conventions for topics, repositories and packages (KlokNamingConventions), and the messages for a missing topic or grant (KlokTopicProvisioning).
  • Message property names carried on every broker message, HTTP request and log line (KlokMessageProperties).
  • The three correlation ids (global, platform, service) and how they are taken from an input (KlokCorrelation), and the log field names every log record in OpenSearch uses (Log fields and correlation).
  • CloudEvents attributes in the binary content mode used on the broker (KlokCloudEventAttributes).
  • The wire contract as data (KlokWireContract), and the KlokCloudEvent interface for datamodels that are events.
  • Small utilities with no Camel or Quarkus dependency: ids, dates, generic type resolution, symmetric encryption, project and domain type enums.
  • The @KlokDocs annotation that marks an important project class for its own documentation page.
  • The shared Klok knowledge blocks (KlokKnowledge), bundled at build time and read once at start.

It has no runtime framework dependency on purpose. The Java modules can depend on it from any layer without cycles, and the names and rules a client in another language must reproduce are stated as data in the wire contract, which the Java constants are tested against and which the TypeScript and Python clients and klok.dev vendor.

Who uses it, and how

  • An integration developer on the Quarkus extension never adds the dependency and rarely calls it, but meets it everywhere: in the topic names a route resolves, in the klok-* properties and MDC keys of every log line, and in the TOPIC_MISSING and TOPIC_ACCESS_DENIED messages that hold the route whose topic is not provisioned (from klok-quarkus-extension 3.14.0; an older extension version stops the whole service instead).
  • A developer of a client or tool outside the extension, in Java or in another language, uses it to produce and read exactly what the platform puts on the broker.
  • The platform maintainer changes and releases it, first in the chain klok-common, broker client, Quarkus extension.

Guides by role walks each of them through what they do.

Versions

The library is published from the main pipeline as <major.minor.patch>+<yyMMddHHmmss> (for example 0.3.0+260910043154) to the GitLab package registry and to Maven Central. Every release updates klokCommon in the dependency catalog klok/framework/klok-gradle-dependency-catalog automatically; a project that follows the catalog, the Quarkus extension and every integration, picks it up with the Gradle plugin task updateKlokLibsToml and never pins the version by hand. Two consumers still pin it themselves: the broker client in its gradle/libs.versions.toml (klok-brokerclient-java#18) and the Gradle plugin in its build.gradle. See Design decisions for why the timestamp is part of the version.

Pages

  • Guides by role: the integration developer, the developer of a client or tool, and the maintainer who changes and releases the library.
  • Naming conventions: topics, request/reply topics, DLQ topics and companions, how topics are provisioned and what TOPIC_MISSING and TOPIC_ACCESS_DENIED tell you to do, repository and package names.
  • Message properties and CloudEvents: the klok-* properties, their MDC keys and the ce-* attributes.
  • Wire contract: the machine-readable contract and fixtures that every client, in any language, is verified against.
  • Utility classes: KlokFastID, KlokGenericTypeResolver, KlokDateHelper, KlokSymmetricEncryption and the enums.
  • The @KlokDocs annotation: marking an important class for its own documentation page.
  • Klok knowledge: the glossary, platform rules and Kloker blocks, bundled by the Gradle plugin.
  • Design decisions.