Skip to content

Add AMQP Imposter selectors - #117

Merged
michalovits merged 3 commits into
bloomberg:mainfrom
michalovits:sync-imposter-selectors
Nov 19, 2026
Merged

michalovits merged 3 commits into
bloomberg:mainfrom
michalovits:sync-imposter-selectors

Conversation

@michalovits

@michalovits michalovits commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor
  • Update documentation
  • Split weighted-sampling and script-rule expressions into Patterns and Selectors
  • Add a control request to watch the transcript stream

We can now write, for example:

script=(
    when_receive(
        # return all mandatory publishes...
        pb.BasicPublishPattern(mandatory=True),
        then_send=pb.BasicReturnPattern(),
    ),
    when_receive(
        pb.BasicPublishPattern(mandatory=False),
        then_send=pb.BasicAckPattern(delivery_tag=message_count, multiple=True),
    ),
    when_send(
        # ...and then multiple-ack them
        pb.BasicReturnPattern(),
        then_send=pb.BasicAckPattern(delivery_tag=message_count, multiple=True),
    ),
),
weights=(
    weighted(pb.BasicAckSelector(), 0),
    weighted(pb.BasicNackSelector(), 0),
)

Previously we reused the weight types in scripts, which brought in a restriction that only existed with weights -- weighted patterns can only express Exact fields.

So we give scripts their own type. We now have Pattern for scripts (which is traditional pattern-matching on the full method spec), and Selector for weights (only the Exact fields).

We also wrap field values in new domain types, which adds runtime validation that e.g. a shortstr is in range, otherwise we'd only catch a bad config when we attempt to frame the then_send.

@michalovits
michalovits force-pushed the sync-imposter-selectors branch from a232f5e to db5392e Compare November 19, 2026 12:32
@michalovits michalovits changed the title Sync imposter selectors Sync AMQP Imposter selectors Nov 19, 2026
@michalovits michalovits changed the title Sync AMQP Imposter selectors Add AMQP Imposter selectors Nov 19, 2026
@michalovits
michalovits marked this pull request as ready for review November 19, 2026 13:04
@michalovits
michalovits force-pushed the sync-imposter-selectors branch from abd91f8 to b2e771a Compare November 19, 2026 13:09
@michalovits
michalovits merged commit 01c4a0f into bloomberg:main Nov 19, 2026
6 checks passed
@michalovits
michalovits deleted the sync-imposter-selectors branch November 19, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants