Skip to main content
Version: 2.32.2

Define Control Points

Aperture Go SDK can be used to define feature control points within a Go service.

Below are the steps to install and use the SDK.

Install SDK

go get github.com/fluxninja/aperture-go/v2

Now, create an instance of Aperture Client.

Create ApertureClient Instance

To create an Aperture Client instance, the address of the organization created in Aperture Cloud and API key are needed. You can locate both these details by clicking on the Aperture tab in the sidebar menu of Aperture Cloud.

Address of your Aperture Cloud is made of Organization ID. For example, if your organization ID is ORGANIZATION and available at port 443 then the address is ORGANIZATION.app.fluxninja.com:443.

API Key

You can create an API key for your project in the Aperture Cloud UI. For detailed instructions on locating API Keys, refer to the API Keys section.

Configuring gRPC Client Options

Aperture Go SDK uses gRPC to communicate with Aperture Cloud. You can configure gRPC client options by passing a list of gRPC client options to the ApertureClient constructor. For request prioritization use cases, it's important to set a high gRPC deadline. This parameter specifies the maximum duration a request can remain in the queue.


Defining Aperture Options and Creating ApertureClient


Define Control Points

Once you have created an instance of ApertureClient, you can define control points.

Define Labels

You can define labels for your control points. These labels can be produced by business logic or can be static. For example, you define a label userId which is the user ID of the user making the request. You can also define a static label version which is the version of your service. Depending on your use case, you can define any number of labels.


Passing Labels using FlowParams

Labels can be passed to the FlowParams struct. This struct is used to pass parameters to the Flow method. Additionally, this struct also defines caching behavior for the control point.


Create Control Point

Once you have defined labels, you can start a flow. To start a flow, you need to provide the control point of the flow and the FlowParams struct.


Control Point Code


To view the working example for more context, refer to the example app available in the repository.

HTTP Middleware

You can also configure middleware for your HTTP server using the SDK. To do this, after creating an instance of ApertureClient, apply the middleware to your router as demonstrated in the example below.

For added convenience, you can specify a list of regular expression patterns. The middleware will only be applied to request paths that match these patterns. This feature is particularly beneficial for endpoints such as /health, /connected which may not require Aperture intervention.