Hi Claus,
I like the bash shell parameter expansion[1], this allows for
specifying the default value if parameter doesn't expand. Something
like {{speedUp:-}} would be optional without a default value, whereas
{{speedUp:-other}} would provide `other` as a default value.

For the REST producer bits I introduced optional parameters with a
trailing question mark, see[2]. Doing something consistent here would
be good I think.

zoran

[1] 
https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion
[2] 
https://github.com/apache/camel/blob/b040a056ddf1b8f0756516cd47c00f180f128c05/core/camel-core/src/test/java/org/apache/camel/component/rest/RestProducerTest.java#L84

On Fri, Mar 5, 2021 at 3:04 PM Claus Ibsen <claus.ib...@gmail.com> wrote:
>
> Hi
>
> In Camel 3.9 we are introducing optional property placeholders.
> https://issues.apache.org/jira/browse/CAMEL-16302
>
> The use-case is to allow configuring Camel endpoints (primarily) where
> you can specify some options that may be configured or not (optional).
>
> Currently all property placeholders are mandatory, unless a default
> value is provided. So with the default value, you could do "optional"
> but then you would need to know what the default value would be (if
> there is any).
>
> Optional placeholders is also a feature that we want to have with
> route templates (aka Kamelets). So you can create kamelets with a
> number of options (some are required, and others would be optional).
> And others have default values etc.
>
> The syntax for marking a property placeholder as option is to prefix
> the key name with ?, eg
>
>      from("jms:cheese?concurrentConsumers={{?speedUp}}")
>
> Here the concurrent consumers option is optional, as the placeholder
> value starts with a ? in the key name.
>
> Then the Camel end user can configure the property placeholder, such
> as in application.properties
>
> speedUp=5
>
> Or if there are no configuration, then the option is not present and
> the endpoint is resolved as:
>
>      from("jms:cheese")
>
>
> The syntax with the ? mark was choose to keep it short. But we are
> open for feedback.
> Another alternative was to prefix with optional:
>
> {{optional:speedUp}}
>
> However the properties component in Camel then assume the key is named
> optional, and the default value is speedUp. So it clashes with this.
> But we could make "optional" a reserved word and do special handling
> for this.
>
> The only concern about using ? is that an endpoint uri already have ?
> for query parameters. And if using more ? would be confusing?
>
>      
> from("jms:cheese?concurrentConsumers={{?speedUp}}&subscrtiptionName={{someName}}")
>
> Any thoughts?
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Zoran Regvart

Reply via email to