mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
Added video link and fixed types (#7942)
Kudos to GitHub for showing the diff despite me renaming the file
This commit is contained in:
parent
500a9c7df4
commit
2ec2639fa3
@ -4,6 +4,8 @@ description: "How to use Unleash feature flags with Ruby."
|
||||
slug: /feature-flag-tutorials/ruby
|
||||
---
|
||||
|
||||
import VideoContent from '@site/src/components/VideoContent.jsx';
|
||||
|
||||
Hello! In this tutorial we’ll show you how to add feature flags to your Ruby app , using [Unleash](https://www.getunleash.io/) and the official [Unleash Ruby SDK](https://docs.getunleash.io/reference/sdks/ruby). With Unleash, an open-source feature flag service, you can use our tooling to add feature flags to your application and release new features faster.
|
||||
|
||||
In a classic tutorial fashion, we’ll get a list of planets from the [Star Wars API](https://swapi.dev/), with just Ruby (i.e., not Ruby on Rails). We’ll use feature flags to decide whether to call the REST or the GraphQL version of the API.
|
||||
@ -17,6 +19,11 @@ In a classic tutorial fashion, we’ll get a list of planets from the [Star Wars
|
||||
- [6. Verify the toggle experience](#6-verify-the-toggle-experience)
|
||||
- [Conclusion](#conclusion)
|
||||
|
||||
Watch the video tutorial and follow along with the code from this documentation.
|
||||
|
||||
|
||||
<VideoContent videoUrls={["https://www.youtube.com/embed/lgR9jUek94U?si=nEX9vnAehlSMpkzw"]}/>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
For this tutorial, you’ll need the following:
|
@ -204,12 +204,13 @@ We want to let you choose the nature of that concurrency, so we're compatible wi
|
||||
```rust
|
||||
use enum_map::Enum;
|
||||
use image::ImageReader;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
use tokio::time::sleep;
|
||||
use unleash_api_client::client::ClientBuilder;
|
||||
use unleash_api_client::Client;
|
||||
use webp::Encoder;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Enum, Clone)]
|
||||
@ -218,8 +219,8 @@ enum Flags {
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
|
||||
let client = ClientBuilder::default().into_client::<Flags, reqwest::Client>(
|
||||
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
let client:Client<Flags, reqwest::Client> = ClientBuilder::default().into_client(
|
||||
"http://localhost:4242/api",
|
||||
"unleash-rust-client-example",
|
||||
"unleash-rust-client-example",
|
||||
@ -232,17 +233,17 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
|
||||
sleep(Duration::from_millis(500)).await;
|
||||
|
||||
let is_webp = client.is_enabled(Flags::webp, None, false);
|
||||
process_images(is_webp)?;
|
||||
process_image(is_webp)?;
|
||||
|
||||
// allow tokio::join to finish
|
||||
client.stop_poll().await;
|
||||
Ok::<(), Box<dyn Error + Send + Sync + 'static>>(())
|
||||
Ok::<(), Box<dyn Error + Send + Sync>>(())
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn process_image(is_webp: bool) -> Result<(), Box<dyn Error>> {
|
||||
fn process_image(is_webp: bool) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
let img = ImageReader::open("input.png")?.decode()?;
|
||||
|
||||
if is_webp {
|
||||
|
Loading…
Reference in New Issue
Block a user