Skip to content

Commit

Permalink
Improved Code Examples in Docs (#2943)
Browse files Browse the repository at this point in the history
### Description of change

##### Checklist

- [ ] Tested in playground or other setup
- [ ] Screenshot (Grafana) from playground added to PR for 15+ minute
run
- [x] Documentation is changed or added
- [ ] Tests and/or benchmarks are included
- [ ] Breaking changes


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Documentation**
- Updated the "Get Started" guide to clarify the process of defining
feature control points and adjusted the terminology for consistency.
- Revised the "Per-User Rate Limiting" guide to reflect changes in
request handling and rate-limiting logic.
- Updated the SDK documentation for .NET to include changes in
initialization and usage with the new C++ code examples.
- Amended the JavaScript SDK manual to align with the updated request
handling function and parameters.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Hardik Shingala <34568645+hdkshingala@users.noreply.github.com>
  • Loading branch information
karansohi and hdkshingala committed Nov 20, 2023
1 parent 489d5e7 commit 6ac3808
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
29 changes: 15 additions & 14 deletions docs/content/get-started/define-control-points.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ export const apertureClient = new ApertureClient({
```

Once you have configured Aperture SDK, you can create a feature control point
wherever you want in your code. Before executing the business logic of a
specific API, you can create a feature control point that can control the
execution flow of the API and can reject the request based on the policy defined
in Aperture. The [Create Your First Policy](./policies/policies.md) section
showcases how to define policy in Aperture. The code snippet below shows how to
wrap your [Control Point](/concepts/control-point.md) within the `StartFlow`
call and pass [labels](/concepts/flow-label.md) that will be matched with
policy. The function `Flow.ShouldRun()` checks if the flow allows the request.
The `Flow.End()` function is responsible for sending telemetry, and updating the
specified cache entry within Aperture.
anywhere within your code. Before executing the business logic of a specific
API, you can create a feature control point that can control the execution flow
of the API and can reject the request based on the policy defined in Aperture.
The [Create Your First Policy](./policies/policies.md) section showcases how to
define policy in Aperture. The code snippet below shows how to wrap your
[Control Point](/concepts/control-point.md) within the `StartFlow` call and pass
[labels](/concepts/flow-label.md) to Aperture Agents. The function
`Flow.ShouldRun()` checks if the flow allows the request. The `Flow.End()`
function is responsible for sending telemetry, and updating the specified cache
entry within Aperture.

Let's create a feature control point in the following code snippet.

Expand All @@ -88,19 +88,20 @@ Let's create a feature control point in the following code snippet.
```

```typescript
async function handleFlow() {
async function handleRequest(req, res) {
const flow = await apertureClient.StartFlow("archimedes-service", {
labels: {
label_key: "api_key",
interval: "60",
api_key: "some_api_key",
},
grpcCallOptions: {
deadline: Date.now() + 1200000, // 20 minutes deadline
deadline: Date.now() + 300, // ms
},
});

if (flow.ShouldRun()) {
// Do Actual Work
// After completing the work, you can return a response, for example:
res.send({ message: "foo" });
} else {
// Handle flow rejection
flow.SetStatus(FlowStatusEnum.Error);
Expand Down
7 changes: 3 additions & 4 deletions docs/content/guides/per-user-rate-limiting.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,13 @@ specified cache entry within Aperture.
```

```javascript
async function handleFlow() {
async function handleRequest(req, res) {
const flow = await apertureClient.StartFlow("awesomeFeature", {
labels: {
label_key: "some_user_id",
interval: "1s",
user_id: "some_user_id",
},
grpcCallOptions: {
deadline: Date.now() + 1200000, // 20 minutes deadline
deadline: Date.now() + 300, // ms
},
});

Expand Down
4 changes: 2 additions & 2 deletions docs/content/sdk/dotnet/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ more information, refer to

:::

```csharp
```cpp
var sdk = ApertureSdk
.Builder()
.SetAddress("ORGANIZATION.app.fluxninja.com:443")
Expand All @@ -38,7 +38,7 @@ var sdk = ApertureSdk

The created instance can then be used to start a flow:

```csharp
```cpp
// do some business logic to collect labels

var labels = new Dictionary<string, string>();
Expand Down
5 changes: 2 additions & 3 deletions docs/content/sdk/javascript/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ export const apertureClient = new ApertureClient({
The created instance can then be used to start a flow:

```javascript
async function handleFlow() {
async function handleRequest(req, res) {
const flow = await apertureClient.StartFlow("feature-name", {
labels: {
label_key: "some_user_id",
interval: "60",
},
grpcCallOptions: {
deadline: Date.now() + 1200000, // 20 minutes deadline
deadline: Date.now() + 300, // ms
},
});

Expand Down

0 comments on commit 6ac3808

Please sign in to comment.