You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Christian Schneider <ch...@die-schneider.net> on 2023/09/18 14:57:24 UTC

Simpler Feature flags for sling

Hi all,

I need to introduce a feature flag to sling code.
I have seen
https://sling.apache.org/documentation/the-sling-engine/featureflags.html
but I think we can do this simpler.

In OSGi R8 there is
https://docs.osgi.org/specification/osgi.core/8.0.0/service.condition.html .
This is ideal for feature toggles.

I propose that we expose feature toggles using a prefix + the toggle name.
So for example it could be "org.apache.sling.toggle.FT-SLING-1234".

I have already experimented with this and it seems feasible.

Code using this can look like this:

@Activate
public MyComponent(
            @Nullable
            @Reference(target =
"(osgi.condition.id=org.apache.sling.toggle.FT_SLING-1234)",
cardinality = ReferenceCardinality.OPTIONAL, policyOption =
ReferencePolicyOption.GREEDY)
            Condition myToggle
            ) {
     boolean myToggleActive = myToggle != null;
}

You can also make the start of a DS component depend on the toggle. (See
examples in the spec).

What do you think?

Christian

-- 
-- 
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com

Re: Simpler Feature flags for sling

Posted by Robert Munteanu <ro...@apache.org>.
On Thu, 2023-09-21 at 11:06 +0200, Robert Munteanu wrote:
> On Thu, 2023-09-21 at 09:07 +0200, Christian Schneider wrote:
> > He proposed a nice alternative to simply use "toggle.FT-SLING-1234"
> > scheme
> > for the Condition ids.
> 
> I think I am still missing context, sorry for being dense :-)
> 
> What does using the toggle mean for a Sling module? I am not sure if
> and how we need to explicitly add these conditions to the source
> code.

Christian and I had a brief chat and I think I get it know :-)

There are two main ways of using OSGi Conditions

1. as a condition for activating OSGi DS components
2. as an optional service reference for OSGi DS components


The first one can be done declaratively but both work programatically,
i.e. declare a reference and check at runtime if the condition is
present.

I personally think that this is fine, given that we document this usage
clearly and we have a proper naming convention for it (Christian
already proposed one).

We should also clarify the relation between using 'toggle conditions'
and the existing feature flags module [1][2].

Christian, please fill in anything that I might've missed.

Thanks,
Robert

[1]: https://github.com/apache/sling-org-apache-sling-featureflags
[2]:
https://sling.apache.org/documentation/the-sling-engine/featureflags.html

Re: Simpler Feature flags for sling

Posted by Robert Munteanu <ro...@apache.org>.
On Thu, 2023-09-21 at 09:07 +0200, Christian Schneider wrote:
> He proposed a nice alternative to simply use "toggle.FT-SLING-1234"
> scheme
> for the Condition ids.

I think I am still missing context, sorry for being dense :-)

What does using the toggle mean for a Sling module? I am not sure if
and how we need to explicitly add these conditions to the source code.

Thanks,
Robert

Re: Simpler Feature flags for sling

Posted by Christian Schneider <ch...@die-schneider.net>.
I spoke to Carsten about how to have feature flags for closed as well as
open source OSGi projects.
He proposed a nice alternative to simply use "toggle.FT-SLING-1234" scheme
for the Condition ids.
This would work universally if all our OSGi projects (Oak, Sling, Felix)
can agree on it.

What do you think?

Christian
Am Di., 19. Sept. 2023 um 13:52 Uhr schrieb Robert Munteanu <
rombert@apache.org>:

> Hi Christian,
>
> On Mon, 2023-09-18 at 16:57 +0200, Christian Schneider wrote:
> > I propose that we expose feature toggles using a prefix + the toggle
> > name.
> > So for example it could be "org.apache.sling.toggle.FT-SLING-1234".
> >
> > I have already experimented with this and it seems feasible.
>
> This looks like a good idea but I'm missing the concrete change you
> propose for Sling :-)
>
> Thanks,
> Robert
>


-- 
-- 
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com

Re: Simpler Feature flags for sling

Posted by Christian Schneider <ch...@die-schneider.net>.
There are two things to decide.
1. If we adopt this scheme in sling. So to decide to use Condition services
like I propose to express dependency on a toggle.
2. I would also like to implement a simple provider for such Condition
services so we can set the toggles without Adobe code and also use them in
tests. I proposed this in felix as it is not only useful in sling.

Christian

Re: Simpler Feature flags for sling

Posted by Robert Munteanu <ro...@apache.org>.
Hi Christian,

On Mon, 2023-09-18 at 16:57 +0200, Christian Schneider wrote:
> I propose that we expose feature toggles using a prefix + the toggle
> name.
> So for example it could be "org.apache.sling.toggle.FT-SLING-1234".
> 
> I have already experimented with this and it seems feasible.

This looks like a good idea but I'm missing the concrete change you
propose for Sling :-)

Thanks,
Robert