Skip to content

prisma-capacity/cqs

Repository files navigation

Prisma CQS

Simple abstractions we use to follow the CQS Principle in applications.

Java CI codecov MavenCentral

Motivation

The CQS Principle states that "every method should either be a command that performs an action, or a query that returns data to the caller, but not both." in order to reduce side-effects.

In our projects we use abstractions like Query & QueryHandler as well as Command & CommandHandler to follow this principle. However, there is a bit of fine print here that makes it worthwhile to reuse this in form of a library:

  • a command / a query needs to be valid (as in java.validation valid), otherwise a Command/Query-ValidationExcption will be thrown
  • a command / a query needs to be valid (determined by an optional message on the handler), otherwise a Command/Query-ValidationExcption will be thrown
  • a command / a query needs to be verified by a mandatory method in the handler the is expected to throw a Command/Query-VerificationException
  • when a command / a query is handled, any exception it may throw is to be wrapped in a Command/Query-Handling Exception

Usage

TODO

Maven

cqs is a parent-only artifact (packaging: pom). For Spring Boot applications, use one of the starter modules:

    <dependency>
      <groupId>eu.prismacapacity</groupId>
      <artifactId>cqs-spring-boot-starter</artifactId>
      <version><!-- put the desired version in here--></version>
    </dependency>

or, for the AOP based integration:

    <dependency>
      <groupId>eu.prismacapacity</groupId>
      <artifactId>cqs-aop-spring-boot-starter</artifactId>
      <version><!-- put the desired version in here--></version>
    </dependency>

For non-Spring usage, use cqs-core as dependency:

    <dependency>
      <groupId>eu.prismacapacity</groupId>
      <artifactId>cqs-core</artifactId>
      <version><!-- put the desired version in here--></version>
    </dependency>

Configuration

TODO

Example

TODO

Configure a retry behaviour for Command and Query handlers

TODO

Migration

TODO

About

Simple abstractions to communicate within one process following the CQS principle.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors