diff mbox series

[FFmpeg-devel] avformat: AMQP: add option delivery_mode

Message ID 20200620171650.105420-1-levis.florian@gmail.com
State New
Headers show
Series [FFmpeg-devel] avformat: AMQP: add option delivery_mode | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Florian Levis June 20, 2020, 5:16 p.m. UTC
Signed-off-by: Levis Florian <levis.florian@gmail.com>
---
 doc/protocols.texi    | 15 +++++++++++++++
 libavformat/libamqp.c |  6 +++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

Comments

Andriy Gelman June 20, 2020, 6:56 p.m. UTC | #1
On Sat, 20. Jun 19:16, Levis Florian wrote:
> Signed-off-by: Levis Florian <levis.florian@gmail.com>
> ---
>  doc/protocols.texi    | 15 +++++++++++++++
>  libavformat/libamqp.c |  6 +++++-
>  2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index 7aa758541c..2e15925eeb 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -109,6 +109,21 @@ the received message may be truncated causing decoding errors.
>  The timeout in seconds during the initial connection to the broker. The
>  default value is rw_timeout, or 5 seconds if rw_timeout is not set.
>  
> +@item delivery_mode @var{mode}
> +Sets the delivery mode of each messages sent.
> +
> +The following values are recognized:
> +@table @samp
> +@item persistent
> +Delivery mode set to "persistent" (2). This is the default value.
> +Messages may be written to the broker's disk depending on its setup.
> +

> +@item non-persistent
> +Delivery mode set to "non-persistent" (1)
> +Messages may be stay in the broker's memory depending on its setup.
> +

I feel the following is clearer:

Messages will stay in broker's memory unless the broker is under memory
pressure.

Let me know if you agree and I'll push in a few days if there are no more
comments.

Thanks,
Florian Levis June 20, 2020, 8:46 p.m. UTC | #2
That's OK for me

--
Florian LEVIS


Le sam. 20 juin 2020 à 20:56, Andriy Gelman <andriy.gelman@gmail.com> a
écrit :

> On Sat, 20. Jun 19:16, Levis Florian wrote:
> > Signed-off-by: Levis Florian <levis.florian@gmail.com>
> > ---
> >  doc/protocols.texi    | 15 +++++++++++++++
> >  libavformat/libamqp.c |  6 +++++-
> >  2 files changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/doc/protocols.texi b/doc/protocols.texi
> > index 7aa758541c..2e15925eeb 100644
> > --- a/doc/protocols.texi
> > +++ b/doc/protocols.texi
> > @@ -109,6 +109,21 @@ the received message may be truncated causing
> decoding errors.
> >  The timeout in seconds during the initial connection to the broker. The
> >  default value is rw_timeout, or 5 seconds if rw_timeout is not set.
> >
> > +@item delivery_mode @var{mode}
> > +Sets the delivery mode of each messages sent.
> > +
> > +The following values are recognized:
> > +@table @samp
> > +@item persistent
> > +Delivery mode set to "persistent" (2). This is the default value.
> > +Messages may be written to the broker's disk depending on its setup.
> > +
>
> > +@item non-persistent
> > +Delivery mode set to "non-persistent" (1)
> > +Messages may be stay in the broker's memory depending on its setup.
> > +
>
> I feel the following is clearer:
>
> Messages will stay in broker's memory unless the broker is under memory
> pressure.
>
> Let me know if you agree and I'll push in a few days if there are no more
> comments.
>
> Thanks,
> --
> Andriy
>
Andriy Gelman June 25, 2020, 3:35 a.m. UTC | #3
On Sat, 20. Jun 22:46, Florian Levis wrote:
> 
> Le sam. 20 juin 2020 à 20:56, Andriy Gelman <andriy.gelman@gmail.com> a
> écrit :
> 
> > On Sat, 20. Jun 19:16, Levis Florian wrote:
> > > Signed-off-by: Levis Florian <levis.florian@gmail.com>
> > > ---
> > >  doc/protocols.texi    | 15 +++++++++++++++
> > >  libavformat/libamqp.c |  6 +++++-
> > >  2 files changed, 20 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/doc/protocols.texi b/doc/protocols.texi
> > > index 7aa758541c..2e15925eeb 100644
> > > --- a/doc/protocols.texi
> > > +++ b/doc/protocols.texi
> > > @@ -109,6 +109,21 @@ the received message may be truncated causing
> > decoding errors.
> > >  The timeout in seconds during the initial connection to the broker. The
> > >  default value is rw_timeout, or 5 seconds if rw_timeout is not set.
> > >
> > > +@item delivery_mode @var{mode}
> > > +Sets the delivery mode of each messages sent.
> > > +
> > > +The following values are recognized:
> > > +@table @samp
> > > +@item persistent
> > > +Delivery mode set to "persistent" (2). This is the default value.
> > > +Messages may be written to the broker's disk depending on its setup.
> > > +
> >
> > > +@item non-persistent
> > > +Delivery mode set to "non-persistent" (1)
> > > +Messages may be stay in the broker's memory depending on its setup.
> > > +
> >
> > I feel the following is clearer:
> >
> > Messages will stay in broker's memory unless the broker is under memory
> > pressure.
> >
> > Let me know if you agree and I'll push in a few days if there are no more
> > comments.
> >
> That's OK for me
> 

Applied.

Thanks,
diff mbox series

Patch

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 7aa758541c..2e15925eeb 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -109,6 +109,21 @@  the received message may be truncated causing decoding errors.
 The timeout in seconds during the initial connection to the broker. The
 default value is rw_timeout, or 5 seconds if rw_timeout is not set.
 
+@item delivery_mode @var{mode}
+Sets the delivery mode of each messages sent.
+
+The following values are recognized:
+@table @samp
+@item persistent
+Delivery mode set to "persistent" (2). This is the default value.
+Messages may be written to the broker's disk depending on its setup.
+
+@item non-persistent
+Delivery mode set to "non-persistent" (1)
+Messages may be stay in the broker's memory depending on its setup.
+
+@end table
+
 @end table
 
 @section async
diff --git a/libavformat/libamqp.c b/libavformat/libamqp.c
index aaf0e51152..81df724a6d 100644
--- a/libavformat/libamqp.c
+++ b/libavformat/libamqp.c
@@ -39,6 +39,7 @@  typedef struct AMQPContext {
     int pkt_size;
     int64_t connection_timeout;
     int pkt_size_overflow;
+    int delivery_mode;
 } AMQPContext;
 
 #define STR_LEN           1024
@@ -52,6 +53,9 @@  static const AVOption options[] = {
     { "exchange", "Exchange to send/read packets", OFFSET(exchange), AV_OPT_TYPE_STRING, { .str = "amq.direct" }, 0, 0, .flags = D | E },
     { "routing_key", "Key to filter streams", OFFSET(routing_key), AV_OPT_TYPE_STRING, { .str = "amqp" }, 0, 0, .flags = D | E },
     { "connection_timeout", "Initial connection timeout", OFFSET(connection_timeout), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, .flags = D | E},
+    { "delivery_mode",  "Delivery mode", OFFSET(delivery_mode), AV_OPT_TYPE_INT, { .i64 = AMQP_DELIVERY_PERSISTENT }, 1, 2, .flags = E, "delivery_mode"},
+    { "persistent",     "Persistent delivery mode",     0, AV_OPT_TYPE_CONST, { .i64 = AMQP_DELIVERY_PERSISTENT }, 0, 0, E, "delivery_mode" },
+    { "non-persistent", "Non-persistent delivery mode", 0, AV_OPT_TYPE_CONST, { .i64 = AMQP_DELIVERY_NONPERSISTENT }, 0, 0, E, "delivery_mode" },
     { NULL }
 };
 
@@ -222,7 +226,7 @@  static int amqp_proto_write(URLContext *h, const unsigned char *buf, int size)
 
     props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG;
     props.content_type = amqp_cstring_bytes("octet/stream");
-    props.delivery_mode = 2; /* persistent delivery mode */
+    props.delivery_mode = s->delivery_mode;
 
     ret = amqp_basic_publish(s->conn, DEFAULT_CHANNEL, amqp_cstring_bytes(s->exchange),
                              amqp_cstring_bytes(s->routing_key), 0, 0,