governance

package
v1.0.0-beta.231 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessReasonFeatureNotFound = &AccessReason{
	Code:    ReasonCodeFeatureNotFound,
	Message: "feature is not found",
}
View Source
var AccessReasonFeatureUnavailable = &AccessReason{
	Code:    ReasonCodeFeatureUnavailable,
	Message: "feature is not available for customer",
}
View Source
var AccessReasonUsageLimitReached = &AccessReason{
	Code:    ReasonCodeUsageLimitReached,
	Message: "usage limit for feature reached",
}

Functions

This section is empty.

Types

type AccessReason

type AccessReason struct {
	Code    ReasonCode
	Message string
}

AccessReason explains why a feature is not accessible.

type CustomerAccess

type CustomerAccess struct {
	// Customer the matched identifiers resolved to.
	Customer customer.Customer
	// Matched lists the request identifiers (customer key or usage-attribution subject
	// key) that resolved to this customer.
	Matched []string
	// Features maps feature key to its access status.
	Features map[string]FeatureAccess
	// UpdatedAt is the time the access state was evaluated.
	UpdatedAt time.Time
}

CustomerAccess is the access evaluation for a single resolved customer.

type FeatureAccess

type FeatureAccess struct {
	HasAccess bool
	// Reason is set when HasAccess is false.
	Reason *AccessReason
}

FeatureAccess is the access status for a single feature.

type QueryAccessInput

type QueryAccessInput struct {
	Namespace string
	// CustomerKeys are arbitrary identifiers — each a customer key or a usage-attribution
	// subject key. Identifiers that cannot be resolved are reported in QueryResult.Errors.
	CustomerKeys []string
	// FeatureKeys, when non-empty, restricts evaluation to those feature keys. When empty,
	// every non-archived feature in the namespace is evaluated.
	FeatureKeys []string
	// IncludeCredits requests credit-balance evaluation. Not yet implemented.
	IncludeCredits bool

	// Pagination over the resolved customers (sorted by CreatedAt, ID). At most one of
	// After/Before may be set.
	PageSize int
	After    *pagination.Cursor
	Before   *pagination.Cursor
}

QueryAccessInput is the input for evaluating governance access.

func (QueryAccessInput) Validate

func (i QueryAccessInput) Validate() error

type QueryError

type QueryError struct {
	// CustomerKey is the request identifier that produced this error.
	CustomerKey string
	Code        QueryErrorCode
	Message     string
}

QueryError is a partial error for a single input identifier.

type QueryErrorCode

type QueryErrorCode string

QueryErrorCode is the machine-readable code for a per-customer query error.

const (
	QueryErrorUnknown          QueryErrorCode = "unknown"
	QueryErrorCustomerNotFound QueryErrorCode = "customer_not_found"
)

type QueryResult

type QueryResult struct {
	// Customers are the access evaluations for the current page, ordered by (CreatedAt, ID).
	Customers []CustomerAccess
	// Errors are partial errors for unresolved input identifiers.
	Errors []QueryError

	// HasPrev/HasNext indicate adjacent pages relative to the current one.
	HasPrev bool
	HasNext bool
	// First/Last are the cursors of the first and last item on the current page.
	First *pagination.Cursor
	Last  *pagination.Cursor
}

QueryResult is the paged result of a governance access query.

type ReasonCode

type ReasonCode string

ReasonCode is the machine-readable reason a customer does not have access to a feature.

const (
	ReasonCodeUnknown            ReasonCode = "unknown"
	ReasonCodeUsageLimitReached  ReasonCode = "usage_limit_reached"
	ReasonCodeFeatureUnavailable ReasonCode = "feature_unavailable"
	ReasonCodeFeatureNotFound    ReasonCode = "feature_not_found"
	ReasonCodeNoCreditAvailable  ReasonCode = "no_credit_available"
)

type Service

type Service interface {
	QueryAccess(ctx context.Context, input QueryAccessInput) (QueryResult, error)
}

Service evaluates feature access for customers by composing the customer, entitlement, and feature services. It owns no persistence of its own.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL