cerk_router_rule_based

Crates.iocerk_router_rule_based
lib.rscerk_router_rule_based
version0.2.11
sourcesrc
created_at2020-11-23 16:29:05.955827
updated_at2021-01-09 17:52:17.740562
descriptionThis is a package for CERK. CERK is an open source CloudEvents Router written in Rust with a MicroKernel architecture.
homepagehttps://github.com/ce-rust/cerk
repositoryhttps://github.com/ce-rust/cerk
max_upload_size
id315453
size15,560
Linus Basig (linuxbasic)

documentation

https://github.com/ce-rust/cerk

README

cerk_router_rule_based

Build status

This is a package for CERK. CERK is an open source CloudEvents Router written in Rust with a MicroKernel architecture.

Introduction

CERK lets you route your CloudEvents between different different ports. Ports are transport layer bindings over which CloudEvents can be exchanged. It is built with modularity and portability in mind.

Components

CERK comes with a couple of prefabricated components, but implementing custom components is easy.

A good overview is provided on GitHub.

This Component: Rule Based Router

The rule-based router routes events based on the given configuration.

The configurations are structured in a tree format. One configuration tree per output port needs to be configured. The operations And, Or, Contains, StartsWith and more are supported.

Configurations

The Socket expects a Config::String as configuration. The string should be a json deserialized routing_rules::RoutingTable.

Configuration Examples

Minimal

Config::String("{}".to_string())

Extended

use serde_json;
use cerk_router_rule_based::{CloudEventFields, RoutingRules, RoutingTable};

let routing_rules: RoutingTable = [(
  "dummy-logger-output".to_string(),
  RoutingRules::And(vec![
    RoutingRules::Exact(
        CloudEventFields::Source,
        Some("dummy.sequence-generator".to_string()),
    ),
    RoutingRules::EndsWith(CloudEventFields::Id, "0".to_string()),
  ]),
)]
.iter()
.cloned()
.collect();

let routing_configs = serde_json::to_string(&routing_rules).unwrap();

Examples

Update Readme

The original readme text is a Rust doc comment in the lib.rs file

  1. cargo install cargo-readme
  2. cargo readme > README.md

License

Apache-2.0

Commit count: 491

cargo fmt