Kobolds

Configuration#

Configuring Kobolds is done through 1 of 2 mechanisms. The Kobolds CLI is used to configure the broker during initialization. After initialization, there is no mechanism of updating the configuration of the broker (yet). The CLI has many ways of of configuring the Broker but the best way is via the broker_config.yaml file.

Broker configuration#

By passing this configuration file to the CLI, the broker can be configured to consume as many or as few resources as required by the application.

# broker_config.yaml
# globally unique ID of the broker. This currently acts as a seed for the `kid` generator. THIS IS A u11 value.
broker_id: 1
# The default encoding of payloads used by the broker if the client does not specify the payload encoding during a
# request/connection.
control_message_encoding: cbor
# the number of worker threads to spawn after initialization
worker_threads: 1
# the number of chunks to spawn per worker. Each chunk is a preallocated block of memory currently 1028 bytes in size.
# Chunks are stored in a pre-allocated memory pool and chained together like a linked list when used for the backing
# memory of messages.
worker_chunk_pool_capacity: 10000
# Currently, only the TCP transport is implemented but in the future the broker will be able
# to listen on multiple ports for different transports, thus serving a wider range of clients.
# <transport>://<ipv4 addr>:<port>
listeners:
    - "tcp://127.0.0.1:7331"
# authorization config and role mappings
authorization:
    roles:
        - name: "default" # name of this role. See how it is mapped under `authentication`
          topics:
              - pattern: "/**" # pattern to be matched for operations
                permissions: # list of permissions assigned to this role
                    - "*" # * | create | read | update (not implemented) | destroy | publish | subscribe | unsubscribe
          services:
              - pattern: "/**" # pattern to be matched for operations
                permissions: # list of permissions assigned to this role
                    - "*" # * | create | read | update (not implemented) | destroy | request | reply
# Authentication and Authorization mappings here. If no mappings are provided, the following 2 defaults are created along with the default permissions.
authentication:
    # Typical username and password authentication
    username_passwords:
        - username: defaul # username of the usert
          password: "kobolds" # password of the user
          roles: # roles assigned to this user
              - default
    pre_shared_keys:
        - secret: kobolds # secret that is used to identify this user. A pre-shared key must be globally unique.
          roles: # roles assigned to this user
              - default

Run the broker using this configuration file

kobolds listen --config-file /path/to/config-file

Client Configuration#

If using the CLI to interact with Kobolds, you can create a client_config.yaml file as well. This file works similarly to the broker_config.yaml (as explained above) but the key differences are that it doesn't manage incoming authentication or authorization. You should note that the connection string must match a configured listener for the broker in order for a connection to be established.

# globally unique client ID seed. this is a u11 value.
client_id: 1
# Connection string used to connect to a broker. Defines the transport, ip and port to be used in the connection.
# <transport>://<ipv4 addr>:<port>
connection_string: tcp://127.0.0.1:7331
# The control message encoding used for all control messages.
control_message_encoding: cbor
# The maxiumum number of connections to be initialized by this client (not implemented)
max_connections: 1
# The number of worker threads to be spawn upon client initialization
worker_threads: 1
# the number of chunks to spawn per worker. Each chunk is a preallocated block of memory currently 1028 bytes in size.
# Chunks are stored in a pre-allocated memory pool and chained together like a linked list when used for the backing
# memory of messages.
worker_chunk_pool_capacity: 10000
# the authentication method to be used by the client. Ensure that this
authentication_method: pre_shared_key
# the algorithm used to encrypt the credentials payload
authentication_algorithm: hmac256 # hmac256 | none
# the credentials to be used for authentication
pre_shared_key:
    secret: "kobolds"
# authentication_method: username_password
# authentication_algorithm: hmac256
# username_password:
#   username: default
#   password: kobolds