configuration gateway

This is the runtime configuration for a casual domain.

The sections can be splitted in arbitrary ways, and aggregated to one configuration model casual uses. Same sections can be defined in different files, hence, give more or less unlimited configuration setup.

Most of the sections has a property note for the user to provide descriptions of the documentation. The examples further down uses this to make it easier to understand the examples by them self. But can of course be used as a mean to help document actual production configuration.

domain.gateway

Defines configuration for communication with other casual domains.

domain.gateway.inbound

Defines all inbound related configuration (from remote domains -> local domain)

Limit (structure)

property

description

[size : integer]

max size in bytes

[messages : integer]

max number of messages in flight

domain.gateway.inbound.default

Will be used as default values for all groups.

property

description

default

[limit : Limit]

default value for limit

[connection.discovery.forward : boolean]

if a discovery is allowed to propagate downstream

false

domain.gateway.inbound.groups.Connection (structure)

Defines a connection that this inbound group should listen to

property

description

default

address : string

the address to listen on, host:port

[discovery.forward : boolean]

if a discovery is allowed to propagate downstream

domain.gateway.inbound.default.connection.discovery.forward

domain.gateway.inbound.groups (list)

Defines a list of all inbound groups

property

description

default

[alias : string]

an identity for this group instance

generated unique name

[limit : Limit]

upper limits of inflight messages

domain.gateway.inbound.default.limit

[connections : [Connection]]

all the connections for this group

domain.gateway.outbound

Defines all outbound related configuration (from local domain -> remote domains)

domain.gateway.outbound.groups.Connection (structure)

Defines a connection that this outbound group should try to connect to.

property

description

address : string

the address to connect to, host:port

[services : [string]]

services we’re expecting to find on the other side

[queues : [string]]

queues we’re expecting to find on the other side

services and queues is used as an optimization to do a build discovery during startup. casual will find these services later lazily otherwise. It can also be used to do some rudimentary load balancing to make sure lower prioritized connections are used for services and queues that could be discovered in higher prioritized connections.

domain.gateway.outbound.groups (list)

Each group gets an order in the order they are defined. Groups defined lower down will only be used if the higher ups does not provide the wanted service or queue. Hence, the lower downs can be used as fallback.

property

description

default

[alias : string]

an identity for this group instance

generated unique name

[connections : [Connection]]

all the connections for this group

All connections within a group ar treated equal, and service calls will be load balanced with round robin. Although, casual will try to route the same transaction to the previous associated connection with the specific transaction. This is only done to minimize the amount of resources involved within the prepare and commit/rollback stage.

domain.gateway.reverse

This section defines reverse inbound and outbound. The connection phase is reversed.

  • outbound connection listen to it’s’ configured address.

  • inbound connections tries to connect to it’s configured address.

Otherwise, the semantics and configuration are exactly the same.

domain.gateway.reverse.inbound

Exactly the same as domain.gateway.inbound

domain.gateway.reverse.outbound

Exactly the same as domain.gateway.outbound

examples

Below follows examples in yaml and json (casual can also handle ini and xml)

yaml

---
domain:
  gateway:
    inbound:
      default:
        note: "discovery forward is disabled default."
        connection:
          discovery:
            forward: false
      groups:
        - alias: "unique-inbound-alias"
          note: "if threshold of 2MB of total payload 'in flight' is reach inbound will stop consume from socket until we're below"
          limit:
            size: 2097152
          connections:
            - address: "localhost:7778"
              note: "can be several listening host:port per inbound instance"
            - address: "some.host.org:7779"
              discovery:
                forward: true
              note: "discovery will be forward to 'all' outbounds"
        - note: "(generated alias) listeners - threshold of either 10 messages OR 10MB - the first that is reach, inbound will stop consume"
          limit:
            size: 10485760
            messages: 10
          connections:
            - address: "some.host.org:7780"
            - address: "some.host.org:4242"
        - note: "(generated alias) listeners - no limits"
          connections:
            - address: "some.host.org:4242"
    outbound:
      groups:
        - alias: "primary"
          note: "casual will 'round-robin' between connections within a group for the same service/queue"
          connections:
            - address: "a45.domain.host.org:7779"
              note: "connection to domain 'a45' - we expect to find service 's1' and 's2' there."
              services:
                - "s1"
                - "s2"
            - address: "a46.domain.host.org:7779"
              note: "we expect to find queues 'q1' and 'q2' and service 's1'"
              services:
                - "s1"
              queues:
                - "q1"
                - "q2"
        - alias: "fallback"
          connections:
            - address: "a99.domain.host.org:7780"
              note: "will be chosen if _resources_ are not found at connections in the 'primary' outbound"
    reverse:
      inbound:
        groups:
          - alias: "unique-alias-name"
            note: "connect to other reverse outbound that is listening on this port - then treat it as a regular inbound"
            limit:
              messages: 42
            connections:
              - address: "localhost:7780"
                note: "one of possible many addresses to connect to"
      outbound:
        groups:
          - alias: "primary"
            note: "listen for connection from reverse inbound - then treat it as a regular outbound"
            connections:
              - address: "localhost:7780"
                note: "one of possible many listining addresses."
          - alias: "secondary"
            note: "onther instance (proces) that handles (multiplexed) traffic on it's own"
            connections:
              - address: "localhost:7781"
                note: "one of possible many listining addresses."
...

json

{
    "domain": {
        "gateway": {
            "inbound": {
                "default": {
                    "note": "discovery forward is disabled default.",
                    "connection": {
                        "discovery": {
                            "forward": false
                        }
                    }
                },
                "groups": [
                    {
                        "alias": "unique-inbound-alias",
                        "note": "if threshold of 2MB of total payload 'in flight' is reach inbound will stop consume from socket until we're below",
                        "limit": {
                            "size": 2097152
                        },
                        "connections": [
                            {
                                "address": "localhost:7778",
                                "note": "can be several listening host:port per inbound instance"
                            },
                            {
                                "address": "some.host.org:7779",
                                "discovery": {
                                    "forward": true
                                },
                                "note": "discovery will be forward to 'all' outbounds"
                            }
                        ]
                    },
                    {
                        "note": "(generated alias) listeners - threshold of either 10 messages OR 10MB - the first that is reach, inbound will stop consume",
                        "limit": {
                            "size": 10485760,
                            "messages": 10
                        },
                        "connections": [
                            {
                                "address": "some.host.org:7780"
                            },
                            {
                                "address": "some.host.org:4242"
                            }
                        ]
                    },
                    {
                        "note": "(generated alias) listeners - no limits",
                        "connections": [
                            {
                                "address": "some.host.org:4242"
                            }
                        ]
                    }
                ]
            },
            "outbound": {
                "groups": [
                    {
                        "alias": "primary",
                        "note": "casual will 'round-robin' between connections within a group for the same service/queue",
                        "connections": [
                            {
                                "address": "a45.domain.host.org:7779",
                                "note": "connection to domain 'a45' - we expect to find service 's1' and 's2' there.",
                                "services": [
                                    "s1",
                                    "s2"
                                ]
                            },
                            {
                                "address": "a46.domain.host.org:7779",
                                "note": "we expect to find queues 'q1' and 'q2' and service 's1'",
                                "services": [
                                    "s1"
                                ],
                                "queues": [
                                    "q1",
                                    "q2"
                                ]
                            }
                        ]
                    },
                    {
                        "alias": "fallback",
                        "connections": [
                            {
                                "address": "a99.domain.host.org:7780",
                                "note": "will be chosen if _resources_ are not found at connections in the 'primary' outbound"
                            }
                        ]
                    }
                ]
            },
            "reverse": {
                "inbound": {
                    "groups": [
                        {
                            "alias": "unique-alias-name",
                            "note": "connect to other reverse outbound that is listening on this port - then treat it as a regular inbound",
                            "limit": {
                                "messages": 42
                            },
                            "connections": [
                                {
                                    "address": "localhost:7780",
                                    "note": "one of possible many addresses to connect to"
                                }
                            ]
                        }
                    ]
                },
                "outbound": {
                    "groups": [
                        {
                            "alias": "primary",
                            "note": "listen for connection from reverse inbound - then treat it as a regular outbound",
                            "connections": [
                                {
                                    "address": "localhost:7780",
                                    "note": "one of possible many listining addresses."
                                }
                            ]
                        },
                        {
                            "alias": "secondary",
                            "note": "onther instance (proces) that handles (multiplexed) traffic on it's own",
                            "connections": [
                                {
                                    "address": "localhost:7781",
                                    "note": "one of possible many listining addresses."
                                }
                            ]
                        }
                    ]
                }
            }
        }
    }
}