plan

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPlanNotFound reports that a plan does not exist.
	ErrPlanNotFound = errors.New("gotenancy/plan: plan not found")

	// ErrPlanAlreadyExists reports that a plan already exists.
	ErrPlanAlreadyExists = errors.New("gotenancy/plan: plan already exists")

	// ErrInvalidPlan reports invalid plan metadata.
	ErrInvalidPlan = errors.New("gotenancy/plan: invalid plan")
)

Functions

This section is empty.

Types

type Feature

type Feature struct {
	Key     string
	Enabled bool
	Config  map[string]string
}

Feature describes a plan feature flag.

type MemoryService

type MemoryService struct {
	// contains filtered or unexported fields
}

MemoryService is a thread-safe in-memory plan service.

func NewMemoryService

func NewMemoryService() *MemoryService

NewMemoryService creates an empty plan service.

func (*MemoryService) Create

func (service *MemoryService) Create(ctx context.Context, plan Plan) error

Create inserts a plan.

func (*MemoryService) Delete

func (service *MemoryService) Delete(ctx context.Context, id string) error

Delete removes a plan.

func (*MemoryService) Get

func (service *MemoryService) Get(ctx context.Context, id string) (Plan, error)

Get returns a plan by ID.

func (*MemoryService) Update

func (service *MemoryService) Update(ctx context.Context, plan Plan) error

Update replaces a plan.

type Plan

type Plan struct {
	ID       string
	Name     string
	Features []Feature
	Quotas   []Quota
}

Plan describes SaaS package capabilities.

type Quota

type Quota struct {
	Resource string
	Limit    int64
	Period   QuotaPeriod
}

Quota describes a plan resource limit.

type QuotaPeriod

type QuotaPeriod string

QuotaPeriod describes the reset period of a quota.

const (
	QuotaPeriodNone  QuotaPeriod = "none"
	QuotaPeriodDay   QuotaPeriod = "day"
	QuotaPeriodMonth QuotaPeriod = "month"
)

type Service

type Service interface {
	Create(ctx context.Context, plan Plan) error
	Get(ctx context.Context, id string) (Plan, error)
	Update(ctx context.Context, plan Plan) error
	Delete(ctx context.Context, id string) error
}

Service manages SaaS plans.

Jump to

Keyboard shortcuts

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