Skip to content

Add per-request buffer_time option#168

Merged
zuiderkwast merged 3 commits into
Ericsson:mainfrom
zuiderkwast:request-buffering
May 26, 2026
Merged

Add per-request buffer_time option#168
zuiderkwast merged 3 commits into
Ericsson:mainfrom
zuiderkwast:request-buffering

Conversation

@zuiderkwast

Copy link
Copy Markdown
Collaborator

Commands can be sent with an optional map of request options:

ered:command(Pid, Cmd, #{buffer_time => 10, timeout => 5000}).

When buffer_time is non-zero, the command is buffered and a timer is started. Buffered commands are flushed when the timer fires. If an unbuffered command (buffer_time => 0, the default) arrives while there are buffered commands, everything is flushed immediately. This allows coalescing multiple commands into fewer TCP packets and TLS records.

The request options map is supported in ered:command/3, ered:command_async/4, ered_cluster:command/4 and ered_cluster:command_async/5. Passing a plain timeout as before still works for backward compatibility.

@bjosv bjosv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits/questions but LGTM

Comment thread src/ered.erl
Comment thread src/ered_cluster.erl Outdated
Comment thread src/ered_cluster.erl
@WilliamVoong

Copy link
Copy Markdown
Collaborator

LGTM

Comment thread src/ered_client.erl Outdated
@WilliamVoong

Copy link
Copy Markdown
Collaborator

Hi, I tested your changes and I think it looks great now 👍

You have my approval for delivery.

Commands can be sent with an optional map of request options:
ered:command(Pid, Cmd, #{buffer_time => 10, timeout => 5000}).

When buffer_time is non-zero, the command is buffered and a timer is
started. Buffered commands are flushed when the timer fires. If an
unbuffered command (buffer_time => 0, the default) arrives while there
are buffered commands, everything is flushed immediately. This allows
coalescing multiple commands into fewer TCP packets and TLS records.

The request options map is supported in ered:command/3,
ered:command_async/4, ered_cluster:command/4 and
ered_cluster:command_async/5. Passing a plain timeout as before
still works for backward compatibility.
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
@zuiderkwast zuiderkwast merged commit 1804665 into Ericsson:main May 26, 2026
10 of 12 checks passed
@zuiderkwast zuiderkwast deleted the request-buffering branch May 26, 2026 10:33
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.

3 participants