diff mbox series

[ovs-dev,v2,10/17] jsonrpc: Add function to update all options at once.

Message ID 20240109225142.1987981-11-i.maximets@ovn.org
State Accepted
Commit 40ce846e8699e90f433964f45bb749c2ddfc1454
Delegated to: Ilya Maximets
Headers show
Series ovsdb-server: Configuration via config-file. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Ilya Maximets Jan. 9, 2024, 10:49 p.m. UTC
It's useful to have a way to update all the JSON-RPC session
options all at once and not call 3 separate functions every
time.  This may also allow the internals of these options
to be better abstracted, i.e. allow users to not know what
are these options exactly.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 lib/jsonrpc.c | 9 +++++++++
 lib/jsonrpc.h | 8 ++++++++
 2 files changed, 17 insertions(+)

Comments

Dumitru Ceara Jan. 12, 2024, 4:33 p.m. UTC | #1
On 1/9/24 23:49, Ilya Maximets wrote:
> It's useful to have a way to update all the JSON-RPC session
> options all at once and not call 3 separate functions every
> time.  This may also allow the internals of these options
> to be better abstracted, i.e. allow users to not know what
> are these options exactly.
> 
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> ---

Acked-by: Dumitru Ceara <dceara@redhat.com>
diff mbox series

Patch

diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index 3db5f76e2..f1ef70950 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -1337,6 +1337,15 @@  jsonrpc_session_set_dscp(struct jsonrpc_session *s, uint8_t dscp)
     }
 }
 
+void
+jsonrpc_session_set_options(struct jsonrpc_session *s,
+                            const struct jsonrpc_session_options *options)
+{
+    jsonrpc_session_set_max_backoff(s, options->max_backoff);
+    jsonrpc_session_set_probe_interval(s, options->probe_interval);
+    jsonrpc_session_set_dscp(s, options->dscp);
+}
+
 /* Sets thresholds for send backlog.  If send backlog contains more than
  * 'max_n_msgs' messages or is larger than 'max_backlog_bytes' bytes,
  * connection will be closed (then reconnected, if that feature is enabled). */
diff --git a/lib/jsonrpc.h b/lib/jsonrpc.h
index 2aa97d3fe..1baffcd80 100644
--- a/lib/jsonrpc.h
+++ b/lib/jsonrpc.h
@@ -139,6 +139,14 @@  void jsonrpc_session_enable_reconnect(struct jsonrpc_session *);
 void jsonrpc_session_force_reconnect(struct jsonrpc_session *);
 void jsonrpc_session_reset_backoff(struct jsonrpc_session *);
 
+struct jsonrpc_session_options {
+    int max_backoff;            /* Maximum reconnection backoff, in msec. */
+    int probe_interval;         /* Max idle time before probing, in msec. */
+    uint8_t dscp;               /* Dscp value for passive connections. */
+};
+
+void jsonrpc_session_set_options(struct jsonrpc_session *,
+                                 const struct jsonrpc_session_options *);
 void jsonrpc_session_set_max_backoff(struct jsonrpc_session *,
                                      int max_backoff);
 void jsonrpc_session_set_probe_interval(struct jsonrpc_session *,