Path: blob/main/components/common-go/experiments/experimentstest/client.go
2500 views
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package experimentstest56import (7"context"89"github.com/gitpod-io/gitpod/common-go/experiments"10)1112type Client struct {13BoolMatcher func(ctx context.Context, experiment string, defaultValue bool, attributes experiments.Attributes) bool14IntMatcher func(ctx context.Context, experimentName string, defaultValue int, attributes experiments.Attributes) int15FloatMatcher func(ctx context.Context, experimentName string, defaultValue float64, attributes experiments.Attributes) float6416StringMatcher func(ctx context.Context, experimentName string, defaultValue string, attributes experiments.Attributes) string17}1819func (c *Client) GetBoolValue(ctx context.Context, experimentName string, defaultValue bool, attributes experiments.Attributes) bool {20if c.BoolMatcher == nil {21return defaultValue22}23return c.BoolMatcher(ctx, experimentName, defaultValue, attributes)24}25func (c *Client) GetIntValue(ctx context.Context, experimentName string, defaultValue int, attributes experiments.Attributes) int {26if c.IntMatcher == nil {27return defaultValue28}29return c.IntMatcher(ctx, experimentName, defaultValue, attributes)30}31func (c *Client) GetFloatValue(ctx context.Context, experimentName string, defaultValue float64, attributes experiments.Attributes) float64 {32if c.FloatMatcher == nil {33return defaultValue34}35return c.FloatMatcher(ctx, experimentName, defaultValue, attributes)36}37func (c *Client) GetStringValue(ctx context.Context, experimentName string, defaultValue string, attributes experiments.Attributes) string {38if c.StringMatcher == nil {39return defaultValue40}41return c.StringMatcher(ctx, experimentName, defaultValue, attributes)42}434445