Skip to content

Channel object have no Traits field #1219

Description

@ivangsa

Channel object have no traits field:

  • it makes it difficult to compose channels with common definitions, specifically channel binding definitions that are by their definition not composable
  • this is not consistent with other asyncapi building blocks like Servers, Messages, Operations

The proposal is to add traits object in the same fashion as other building blocks

Describe the solution you'd like

Add a Channel Trait Object and a traits field to the Channel Object, mirroring Operation Traits and Message Traits exactly:

  • A traits array on the Channel Object.
  • A channelTraits map under the Components Object for reuse.
  • The same trait merge mechanism already defined for operations and messages. Traits apply in order; the Channel Object's own values take precedence. The merged result MUST be a valid Channel Object.
    The Channel Trait Object carries the composable subset of channel fields (everything except the channel identity fields address and messages, and traits itself).

Example: compose Kafka bindings without exploding combinations

components:
  channelTraits:
    kafkaReplicated:
      bindings:
        kafka:
          partitions: 6
          replicas: 3
    kafkaCompacted:
      bindings:
        kafka:
          topicConfiguration:
            cleanup.policy: [compact]
 
channels:
  userSignedUp:
    address: user.signedup
    traits:
      - $ref: '#/components/channelTraits/kafkaReplicated'
      - $ref: '#/components/channelTraits/kafkaCompacted'
    messages:
      userSignedUp:
        $ref: '#/components/messages/UserSignedUp'

Two orthogonal binding profiles compose into one channel instead of requiring a replicated-compacted channel definition. Add a third axis (e.g. retention) and you add one trait, not a multiplied set of channels.

Champion

@ivangsa — will drive the proposal PR, JSON Schema changes, and parser implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions