Socket
Socket
Sign inDemoInstall

go.flipt.io/flipt/sdk/go

Package Overview
Dependencies
15
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    go.flipt.io/flipt/sdk/go

Package sdk is the official Flipt Go SDK. The SDK exposes the various RPC for interfacing with a remote Flipt instance. Both HTTP and gRPC protocols are supported via this unified Go API. The main entrypoint within this package is New, which takes an instance of Transport and returns an instance of SDK. Transport implementations can be found in the following sub-packages: The following is an example of creating and instance of the SDK using the gRPC transport. The following is an example of creating an instance of the SDK using the HTTP transport. The remote procedure calls mades by this SDK are authenticated via a ClientAuthenticationProvider implementation. This can be supplied to New via the WithAuthenticationProvider option. Note that each of these methods will only work if the target Flipt server instance has the authentication method enabled. Currently, there are three implementations: - StaticTokenAuthenticationProvider(https://www.flipt.io/docs/authentication/methods#static-token): This provider sets a static Flipt client token via the Authentication header with the Bearer scheme. - JWTAuthenticationProvider(https://www.flipt.io/docs/authentication/methods#json-web-tokens): This provider sets a pre-generated JSON web-token via the Authentication header with the JWT scheme. - KubernetesAuthenticationProvider(https://www.flipt.io/docs/authentication/methods#kubernetes): This automatically uses the service account token on the host and exchanges it with Flipt for a Flipt client token credential. The credential is then used to authenticate requests, again via the Authentication header and the Bearer scheme. It ensures that the client token is not-expired and requests fresh tokens automatically without intervention. Use this method to automatically authenticate your application with a Flipt deployed into the same Kubernetes cluster. The Flipt SDK is split into four sections Flipt, Auth, Meta, and Evaluation. Each of which provides access to different parts of the Flipt system. The Flipt service is the core Flipt API service. This service provides access to the Flipt resource CRUD APIs. Flipt resources can be accessed and managed directly. The Evaluation service provides access to the Flipt evaluation APIs. The Evaluation service provides three methods for evaluating a flag for a given entity: Boolean, Variant, and Batch. The Boolean method returns a response containing a boolean value indicating whether or not the flag is enabled for the given entity. Learn more about the Boolean flag type: <https://www.flipt.io/docs/concepts#boolean-flags> The Variant method returns a response containing the variant key for the given entity. Learn more about the Variant flag type: <https://www.flipt.io/docs/concepts#variant-flags> The Batch method returns a response containing the evaluation results for a batch of requests. These requests can be for a mix of boolean and variant flags.


Version published

Readme

Source

Flipt Go SDK

Go Reference

The Flipt Go SDK supports developing applications in Go against Flipt. It also supports the ability to access the resource management APIs and other systems, such as authentication and metadata.

The SDK supports both Flipts gRPC and HTTP RPC APIs. A majority of this client is generated directly from Flipt's protobuf definitions. The Flipt SDK Generator can be found locally within this repository.

Dependencies

  • Go >= v1.20

Client / Server Version Compatibility

client ⌄ / server ›<= 1.19.*>= 1.20.0
0.1.*✓*
>= 0.2.*

* Backwards compatible, but can only access the "default" namespace.

Get the SDK

go get go.flipt.io/flipt/sdk/go

Construct and Authenticate the SDK

Constructing an SDK client is easy.

  1. Pick your transport of choice. Bothgrpc or http are sub-packages with respective implementations.
  2. Pass a constructed Transport implementation to sdk.New(...).
  3. Optionally pass in a sdk.ClientTokenProvider to authenticate your RPC calls.
package main

import (
	sdk "go.flipt.io/flipt/sdk/go"
	sdkgrpc "go.flipt.io/flipt/sdk/go/grpc"
	grpc "google.golang.org/grpc"
)

func main() {
	token := sdk.StaticClientTokenProvider("a-flipt-client-token")

	conn := grpc.Dial("localhost:9090")
	transport := sdkgrpc.NewTransport(conn)

	client := sdk.New(transport, sdk.WithClientTokenProvider(token))
}

FAQs

Last updated on 09 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc