Ah there is already the "?speedUp" notation to describe it as optional in
camel-main. Then I'm fine with {{?speedUp}} syntax to maintain consistency
within Camel.
https://camel.apache.org/components/latest/others/main.html#_optional_parameters_on_beans

On Mon, Mar 8, 2021 at 2:25 PM Tadayoshi Sato <sato.tadayo...@gmail.com>
wrote:

> Hi Zoran,
>
> Just in case, Properties component already provide the feature of
> specifying a default value with {{speedUp:other}} syntax:
> https://camel.apache.org/components/3.7.x/properties-component.html#_syntax
>
> So what Claus proposes here is a feature that optionally can assign some
> value but otherwise leaves it unassigned at all.
> I see Claus' point that the syntax {{optional:speedUp}} is really
> confusing as the properties component would then see it as the placeholder
> "optional" with default value "speedUp".
>
> Personally, I second Babak's syntax of {{speedUp?}} as it aligns with JS
> syntax and REST producer optional parameters Zoran introduced.
>
> Best regards,
> Tadayoshi
>
> On Sat, Mar 6, 2021 at 4:41 AM Zoran Regvart <zo...@regvart.com> wrote:
>
>> 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
>>
>
>
> --
> Tadayoshi Sato
>


-- 
Tadayoshi Sato

Reply via email to