Skip to content

Commit

Permalink
deploy: b4e047f
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcardell committed Sep 10, 2024
1 parent add4924 commit 8ad3392
Showing 1 changed file with 42 additions and 15 deletions.
57 changes: 42 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,31 +95,58 @@ <h1 id="ff4s-feature-flags-for-scala" class="title">ff4s - Feature Flags For Sca

<h2 id="features" class="section"><a class="anchor-link left" href="#features"><i class="icofont-laika link">&#xef71;</i></a>Features</h2>
<ul>
<li>✅ Cross-platform, cross-version Scala feature flagging</li>
<li><a href="https://flipt.io">Flipt</a> client</li>
<li>🚧 <a href="https://openfeature.dev">OpenFeature</a> SDK</li>
<li>🚧 Flipt OpenFeature provider</li>
<li>Cross-platform, cross-version Scala feature flagging</li>
<li><a href="https://flipt.io">Flipt</a> client</li>
<li>
<a href="https://openfeature.dev">OpenFeature</a> SDK
<ul>
<li>Provider Evaluation</li>
<li>🚧 Hooks</li>
</ul>
</li>
<li>Flipt OpenFeature provider</li>
<li>LaunchDarkly OpenFeature provider with <a href="https://typelevel.org/catapult">Catalyst</a></li>
</ul>

<h2 id="installing" class="section"><a class="anchor-link left" href="#installing"><i class="icofont-laika link">&#xef71;</i></a>Installing</h2>
<pre class="keep-together pdf epub"><code class="nohighlight"><span class="identifier">libraryDependencies</span><span> += </span><span class="string-literal">&quot;io.cardell&quot;</span><span> %%% </span><span class="string-literal">&quot;ff4s-flipt-server-sdk&quot;</span><span> % </span><span class="string-literal">&quot;0.1.2&quot;</span></code></pre>
<pre class="keep-together pdf epub"><code class="nohighlight"><span class="identifier">libraryDependencies</span><span> += </span><span class="string-literal">&quot;io.cardell&quot;</span><span> %%% </span><span class="string-literal">&quot;flipt-sdk-server&quot;</span><span> % </span><span class="string-literal">&quot;0.1.2&quot;</span><span>
</span><span class="comment">// or
</span><span class="identifier">libraryDependencies</span><span> ++= </span><span class="type-name">Seq</span><span>(
</span><span class="string-literal">&quot;io.cardell&quot;</span><span> %%% </span><span class="string-literal">&quot;openfeature-sdk&quot;</span><span> % </span><span class="string-literal">&quot;0.1.2&quot;</span><span>,
</span><span class="comment">// for circe json variant types
</span><span> </span><span class="string-literal">&quot;io.cardell&quot;</span><span> %%% </span><span class="string-literal">&quot;openfeature-sdk-circe&quot;</span><span> % </span><span class="string-literal">&quot;0.1.2&quot;</span><span>,
</span><span class="comment">// to use flipt as a backend
</span><span> </span><span class="string-literal">&quot;io.cardell&quot;</span><span> %%% </span><span class="string-literal">&quot;openfeature-provider-flipt&quot;</span><span> % </span><span class="string-literal">&quot;0.1.2&quot;</span><span>
)</span></code></pre>

<h2 id="openfeature-usage" class="section"><a class="anchor-link left" href="#openfeature-usage"><i class="icofont-laika link">&#xef71;</i></a>OpenFeature Usage</h2>
<p>The OpenFeature SDK adds features like handling default values in case of errors.
Eventually the SDK will cover the full range of the <a href="https://openfeature.dev">openfeature</a>
specification, like hooks, events, static vs dynamic context.</p>
<p>See <code>Flipt usage</code> on how to set up the <code>FliptApi</code>. Once done, set up a provider:</p>
<pre class="keep-together pdf epub"><code class="nohighlight"><span class="keyword">import</span><span> </span><span class="identifier">cats</span><span>.</span><span class="identifier">effect</span><span>.</span><span class="type-name">IO</span><span>
<pre><code class="nohighlight"><span class="keyword">import</span><span> </span><span class="identifier">cats</span><span>.</span><span class="identifier">effect</span><span>.</span><span class="type-name">IO</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">circe</span><span>.</span><span class="type-name">Decoder</span><span>

</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">flipt</span><span>.</span><span class="type-name">FliptApi</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">openfeature</span><span>.</span><span class="type-name">OpenFeature</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">ff4s</span><span>.</span><span class="identifier">flipt</span><span>.</span><span class="type-name">FliptApi</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">openfeature</span><span>.</span><span class="identifier">provider</span><span>.</span><span class="identifier">flipt</span><span>.</span><span class="type-name">FliptProvider</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">openfeature</span><span>.</span><span class="identifier">circe</span><span>.</span><span class="identifier">_</span><span>

</span><span class="keyword">def</span><span> </span><span class="declaration-name">provider</span><span>(</span><span class="identifier">flipt</span><span>: </span><span class="type-name">FliptApi</span><span>[</span><span class="type-name">IO</span><span>]) = {
</span><span class="keyword">case</span><span> </span><span class="keyword">class</span><span> </span><span class="type-name">SomeVariant</span><span>(</span><span class="identifier">field</span><span>: </span><span class="type-name">String</span><span>, </span><span class="identifier">field2</span><span>: </span><span class="type-name">Int</span><span>)

</span><span class="keyword">def</span><span> </span><span class="declaration-name">provider</span><span>(</span><span class="identifier">flipt</span><span>: </span><span class="type-name">FliptApi</span><span>[</span><span class="type-name">IO</span><span>])(</span><span class="keyword">implicit</span><span> </span><span class="identifier">d</span><span>: </span><span class="type-name">Decoder</span><span>[</span><span class="type-name">SomeVariant</span><span>]) = {
</span><span class="keyword">val</span><span> </span><span class="identifier">featureSdk</span><span> = </span><span class="type-name">OpenFeature</span><span>[</span><span class="type-name">IO</span><span>](</span><span class="keyword">new</span><span> </span><span class="type-name">FliptProvider</span><span>[</span><span class="type-name">IO</span><span>](</span><span class="identifier">flipt</span><span>, </span><span class="string-literal">&quot;some-namespace&quot;</span><span>))

</span><span class="identifier">featureSdk</span><span>.</span><span class="identifier">client</span><span>.</span><span class="identifier">flatMap</span><span> { </span><span class="identifier">featureClient</span><span> =&gt;
</span><span class="identifier">featureClient</span><span>.</span><span class="identifier">getBooleanValue</span><span>(</span><span class="string-literal">&quot;boolean-flag&quot;</span><span>, </span><span class="boolean-literal">false</span><span>)
</span><span class="keyword">for</span><span> {
</span><span class="identifier">eval</span><span> &lt;- </span><span class="identifier">featureClient</span><span>.</span><span class="identifier">getBooleanValue</span><span>(</span><span class="string-literal">&quot;boolean-flag&quot;</span><span>, </span><span class="boolean-literal">false</span><span>)
</span><span class="identifier">_</span><span> &lt;- </span><span class="type-name">IO</span><span>.</span><span class="identifier">println</span><span>(</span><span class="string-literal">s&quot;</span><span class="substitution">${eval}</span><span class="string-literal">&quot;</span><span>)
</span><span class="identifier">eval2</span><span> &lt;- </span><span class="identifier">featureClient</span><span>.</span><span class="identifier">getStructureValue</span><span>[</span><span class="type-name">SomeVariant</span><span>](
</span><span class="string-literal">&quot;structure-flag&quot;</span><span>,
</span><span class="type-name">SomeVariant</span><span>(</span><span class="string-literal">&quot;a&quot;</span><span>, </span><span class="number-literal">1</span><span>)
)
</span><span class="identifier">_</span><span> &lt;- </span><span class="type-name">IO</span><span>.</span><span class="identifier">println</span><span>(</span><span class="string-literal">s&quot;</span><span class="substitution">${eval2}</span><span class="string-literal">&quot;</span><span>)
} </span><span class="keyword">yield</span><span> ()
}
}</span></code></pre>

Expand All @@ -128,9 +155,9 @@ <h2 id="flipt-usage" class="section"><a class="anchor-link left" href="#flipt-us
<pre><code class="nohighlight"><span class="keyword">import</span><span> </span><span class="identifier">cats</span><span>.</span><span class="identifier">effect</span><span>.</span><span class="type-name">IO</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">org</span><span>.</span><span class="identifier">http4s</span><span>.</span><span class="identifier">ember</span><span>.</span><span class="identifier">client</span><span>.</span><span class="type-name">EmberClientBuilder</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">org</span><span>.</span><span class="identifier">http4s</span><span>.</span><span class="type-name">Uri</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">ff4s</span><span>.</span><span class="identifier">flipt</span><span>.</span><span class="type-name">FliptApi</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">ff4s</span><span>.</span><span class="identifier">flipt</span><span>.</span><span class="type-name">EvaluationRequest</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">ff4s</span><span>.</span><span class="identifier">flipt</span><span>.</span><span class="identifier">auth</span><span>.</span><span class="type-name">AuthenticationStrategy</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">flipt</span><span>.</span><span class="type-name">FliptApi</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">flipt</span><span>.</span><span class="type-name">EvaluationRequest</span><span>
</span><span class="keyword">import</span><span> </span><span class="identifier">io</span><span>.</span><span class="identifier">cardell</span><span>.</span><span class="identifier">flipt</span><span>.</span><span class="identifier">auth</span><span>.</span><span class="type-name">AuthenticationStrategy</span><span>

</span><span class="keyword">val</span><span> </span><span class="identifier">url</span><span>: </span><span class="type-name">Uri</span><span> = </span><span class="type-name">Uri</span><span>.</span><span class="identifier">unsafeFromString</span><span>(</span><span class="string-literal">&quot;https://flipt.example.com&quot;</span><span>)
</span><span class="comment">// url: Uri = Uri(
Expand Down Expand Up @@ -158,9 +185,9 @@ <h2 id="flipt-usage" class="section"><a class="anchor-link left" href="#flipt-us
</span><span class="comment">// resource: cats.effect.kernel.Resource[IO, FliptApi[IO]] = Bind(
// source = Bind(
// source = Eval(fa = Pure(value = ())),
// fs = org.http4s.ember.client.EmberClientBuilder$$Lambda$12540/0x00000008020a6040@45c73ea0
// fs = org.http4s.ember.client.EmberClientBuilder$$Lambda$13347/0x000000080360f040@694894d6
// ),
// fs = cats.effect.kernel.Resource$$Lambda$12541/0x0000000802161040@7a664f53
// fs = cats.effect.kernel.Resource$$Lambda$13348/0x000000080360d840@6e9c23ca
// )
</span><span>
</span><span class="identifier">resource</span><span>.</span><span class="identifier">use</span><span> { </span><span class="identifier">flipt</span><span> =&gt;
Expand All @@ -178,7 +205,7 @@ <h2 id="flipt-usage" class="section"><a class="anchor-link left" href="#flipt-us
}
</span><span class="comment">// res0: IO[Boolean] = FlatMap(
// ioe = Pure(value = ()),
// f = cats.effect.kernel.Resource$$Lambda$12543/0x00000008020c9840@ff02197,
// f = cats.effect.kernel.Resource$$Lambda$13350/0x000000080360c040@430ae8c3,
// event = cats.effect.tracing.TracingEvent$StackTrace
// )</span></code></pre>

Expand Down

0 comments on commit 8ad3392

Please sign in to comment.