Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions internal/flags/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func TestMemoryRepository_Create(t *testing.T) {
Type: flags.FlagBool,
Enabled: true,
DefaultValue: flags.BoolValue(false),
Version: 1,
UpdatedAt: time.Now(),
}

Expand Down Expand Up @@ -58,7 +57,6 @@ func TestMemoryRepository_Get(t *testing.T) {
Type: flags.FlagBool,
Enabled: true,
DefaultValue: flags.BoolValue(true),
Version: 1,
}

require.NoError(t, repo.Create(ctx, flag))
Expand Down
5 changes: 0 additions & 5 deletions internal/flags/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ func NewServiceWithMatcher(repo Repository, matcher RuleMatcher) *Service {
func (s *Service) Create(ctx context.Context, flag *Flag) error {
flag.UpdatedAt = time.Now()

if flag.Version == 0 {
flag.Version = 1
}

return s.repo.Create(ctx, flag)
}

Expand All @@ -42,7 +38,6 @@ func (s *Service) Evaluate(ctx context.Context, key string, evalCtx EvalContext)

result := &EvalResult{
FlagKey: key,
Version: flag.Version,
EvaluatedAt: time.Now(),
}

Expand Down
1 change: 0 additions & 1 deletion internal/flags/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func TestService_Create(t *testing.T) {
err := svc.Create(ctx, flag)
require.NoError(t, err)

assert.Equal(t, int64(1), flag.Version)
assert.False(t, flag.UpdatedAt.IsZero())
}

Expand Down
35 changes: 3 additions & 32 deletions internal/flags/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ type Flag struct {
Enabled bool // global kill switch
DefaultValue Value
Rules []Rule // ordered: first match wins
Version int64
UpdatedAt time.Time
}

type Rule struct {
ID string
Conditions []Condition // AND across conditions
Value Value
Rollout *Rollout // optional percentage rollout gate
}

type ConditionOp string
Expand All @@ -44,30 +42,6 @@ type Condition struct {
Value any // string | float64 | bool | []any depending on Op
}

type Rollout struct {
Percentage int // 0..100
Salt string // changes bucket assignment when rotated
Subject string // "user" or "tenant" (who gets bucketed)
}

type OverrideScope string

const (
ScopeUser OverrideScope = "user"
ScopeTenant OverrideScope = "tenant"
)

type Override struct {
FlagKey string
Scope OverrideScope
SubjectID string // user_id or tenant_id
Value Value
Reason string
CreatedAt time.Time
CreatedBy string
ExpiresAt *time.Time // optional safety valve
}

type Value struct {
Kind FlagType
Bool *bool
Expand Down Expand Up @@ -96,18 +70,15 @@ type EvalContext struct {
type EvalReason string

const (
ReasonDisabled EvalReason = "disabled"
ReasonUserOverride EvalReason = "user_override"
ReasonTenantOverride EvalReason = "tenant_override"
ReasonRuleMatch EvalReason = "rule_match"
ReasonDefault EvalReason = "default"
ReasonDisabled EvalReason = "disabled"
ReasonRuleMatch EvalReason = "rule_match"
ReasonDefault EvalReason = "default"
)

type EvalResult struct {
FlagKey string
Value Value
Reason EvalReason
RuleID string
Version int64
EvaluatedAt time.Time
}
1 change: 0 additions & 1 deletion internal/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func (h *Handler) CreateFlag(ctx context.Context, req *CreateFlagRequest) (*Crea
return &CreateFlagResponse{
Body: CreateFlagResponseBody{
Key: flag.Key,
Version: flag.Version,
CreatedAt: flag.UpdatedAt,
},
}, nil
Expand Down
1 change: 0 additions & 1 deletion internal/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func TestHandler_CreateFlag(t *testing.T) {
require.NoError(t, err)

assert.Equal(t, "test-flag", resp.Body.Key)
assert.Equal(t, int64(1), resp.Body.Version)
assert.False(t, resp.Body.CreatedAt.IsZero())
}

Expand Down
1 change: 0 additions & 1 deletion internal/handler/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func ToEvalResultBody(result *flags.EvalResult) EvalResultBody {
Value: toValueBody(result.Value),
Reason: string(result.Reason),
RuleID: result.RuleID,
Version: result.Version,
EvaluatedAt: result.EvaluatedAt,
}
}
Expand Down
2 changes: 0 additions & 2 deletions internal/handler/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func TestToEvalResultBody(t *testing.T) {
},
Reason: flags.ReasonRuleMatch,
RuleID: "rule-1",
Version: 5,
EvaluatedAt: now,
}

Expand All @@ -108,7 +107,6 @@ func TestToEvalResultBody(t *testing.T) {
assert.True(t, *body.Value.Bool)
assert.Equal(t, "rule_match", body.Reason)
assert.Equal(t, "rule-1", body.RuleID)
assert.Equal(t, int64(5), body.Version)
assert.Equal(t, now, body.EvaluatedAt)
}

Expand Down
2 changes: 0 additions & 2 deletions internal/handler/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type CreateFlagResponse struct {

type CreateFlagResponseBody struct {
Key string `json:"key"`
Version int64 `json:"version"`
CreatedAt time.Time `json:"createdAt"`
}

Expand All @@ -69,6 +68,5 @@ type EvalResultBody struct {
Value ValueBody `json:"value"`
Reason string `json:"reason"`
RuleID string `json:"ruleId,omitempty"`
Version int64 `json:"version"`
EvaluatedAt time.Time `json:"evaluatedAt"`
}