service

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Products = []Product{
	{
		Key:                      "stored_data",
		Name:                     "Stored data",
		Price:                    0.03 / gib,
		PriceType:                PriceTypeTemporal,
		FreeQuotaSize:            5 * gib,
		FreeQuotaGracePeriodSize: 1000 * gib,
		FreeQuotaInterval:        FreeQuotaMonthly,
		Units:                    "bytes",
		UnitSize:                 8 * mib,
	},
	{
		Key:                      "network_egress",
		Name:                     "Network egress",
		Price:                    0.1 / gib,
		PriceType:                PriceTypeIncremental,
		FreeQuotaSize:            10 * gib,
		FreeQuotaGracePeriodSize: 1000 * gib,
		FreeQuotaInterval:        FreeQuotaMonthly,
		Units:                    "bytes",
		UnitSize:                 8 * mib,
	},
	{
		Key:                      "instance_reads",
		Name:                     "ThreadDB reads",
		Price:                    0.1 / 100000,
		PriceType:                PriceTypeIncremental,
		FreeQuotaSize:            50000,
		FreeQuotaGracePeriodSize: 1000000,
		FreeQuotaInterval:        FreeQuotaDaily,
		UnitSize:                 100,
	},
	{
		Key:                      "instance_writes",
		Name:                     "ThreadDB writes",
		Price:                    0.2 / 100000,
		PriceType:                PriceTypeIncremental,
		FreeQuotaSize:            20000,
		FreeQuotaGracePeriodSize: 1000000,
		FreeQuotaInterval:        FreeQuotaDaily,
		UnitSize:                 100,
	},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	ListenAddr ma.Multiaddr

	StripeAPIURL           string
	StripeAPIKey           string
	StripeSessionReturnURL string
	StripeWebhookSecret    string

	SegmentAPIKey string
	SegmentPrefix string

	DBURI  string
	DBName string

	GatewayHostAddr ma.Multiaddr

	FreeQuotaGracePeriod time.Duration

	Debug bool
}

type Customer

type Customer struct {
	Key                string          `bson:"_id"`
	CustomerID         string          `bson:"customer_id"`
	ParentKey          string          `bson:"parent_key"`
	Email              string          `bson:"email"`
	AccountType        mdb.AccountType `bson:"account_type"`
	SubscriptionStatus string          `bson:"subscription_status"`
	Balance            int64           `bson:"balance"`
	Billable           bool            `bson:"billable"`
	Delinquent         bool            `bson:"delinquent"`
	CreatedAt          int64           `bson:"created_at"`
	GracePeriodStart   int64           `bson:"grace_period_start"`

	InvoicePeriod Period `bson:"invoice_period"`

	DailyUsage map[string]Usage `bson:"daily_usage"`
}

func (*Customer) AccountStatus

func (c *Customer) AccountStatus() string

type FreeQuotaInterval

type FreeQuotaInterval string
const (
	FreeQuotaMonthly FreeQuotaInterval = "monthly"
	FreeQuotaDaily                     = "daily"
)

type Period

type Period struct {
	UnixStart int64 `bson:"unix_start"`
	UnixEnd   int64 `bson:"unix_end"`
}

type PriceType

type PriceType string
const (
	PriceTypeTemporal    PriceType = "temporal"
	PriceTypeIncremental           = "incremental"
)

type Product

type Product struct {
	Key                      string            `bson:"_id"`
	Name                     string            `bson:"name"`
	Price                    float64           `bson:"price"`
	PriceType                PriceType         `bson:"price_type"`
	FreeQuotaSize            int64             `bson:"free_quota_size"`
	FreeQuotaGracePeriodSize int64             `bson:"free_quota_grace_period_size"`
	FreeQuotaInterval        FreeQuotaInterval `bson:"free_quota_interval"`

	Units    string `bson:"units"`
	UnitSize int64  `bson:"unit_size"`

	FreePriceID string `bson:"free_price_id"`
	PaidPriceID string `bson:"paid_price_id"`
}

type Service

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

func NewService

func NewService(ctx context.Context, config Config) (*Service, error)

func (*Service) CheckHealth

func (*Service) CreateCustomer

func (s *Service) CreateCustomer(ctx context.Context, req *pb.CreateCustomerRequest) (
	*pb.CreateCustomerResponse, error)

func (*Service) DeleteCustomer

func (s *Service) DeleteCustomer(ctx context.Context, req *pb.DeleteCustomerRequest) (
	*pb.DeleteCustomerResponse, error)

func (*Service) GetCustomer

func (s *Service) GetCustomer(ctx context.Context, req *pb.GetCustomerRequest) (
	*pb.GetCustomerResponse, error)

func (*Service) GetCustomerSession

func (s *Service) GetCustomerSession(ctx context.Context, req *pb.GetCustomerSessionRequest) (
	*pb.GetCustomerSessionResponse, error)

func (*Service) GetCustomerUsage added in v2.1.5

func (s *Service) GetCustomerUsage(
	ctx context.Context,
	req *pb.GetCustomerUsageRequest,
) (*pb.GetCustomerUsageResponse, error)

func (*Service) IncCustomerUsage

func (s *Service) IncCustomerUsage(
	ctx context.Context,
	req *pb.IncCustomerUsageRequest,
) (*pb.IncCustomerUsageResponse, error)

func (*Service) ListDependentCustomers

func (*Service) ReportCustomerUsage added in v2.1.5

func (s *Service) ReportCustomerUsage(
	ctx context.Context,
	req *pb.ReportCustomerUsageRequest,
) (*pb.ReportCustomerUsageResponse, error)

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop(force bool) error

func (*Service) UpdateCustomer

func (s *Service) UpdateCustomer(ctx context.Context, req *pb.UpdateCustomerRequest) (
	*pb.UpdateCustomerResponse, error)

type Usage

type Usage struct {
	Total int64 `bson:"total"`

	FreeItemID string `bson:"free_item_id"`
	PaidItemID string `bson:"paid_item_id"`
}

Jump to

Keyboard shortcuts

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