idtype

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 17, 2017 License: BSD-3-Clause Imports: 1 Imported by: 10

Documentation

Overview

Package idtype contains our enumeration of all registered types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(typ Type, mutable bool, name string)

Register registers a type into the global namespace, allowing lookup of its mutable and name properties from only the bytes that make up the type.

We use this when determining a type from an ID. Any types used *must* be registered. Ideally, call this from your package's init function.

Register panics if it is called twice with the same Type.

Types

type Type

type Type uint16

Type is the enumerated list of all registered types, global within the marketplace. Types are encoded within 12 bits in an ID, allowing for 4096 distinct types.

var (
	// users, orgs, teams
	User                Type = 0x000 // User object
	ForgotPasswordToken Type = 0x001 // ForgotPasswordToken object

	// Authentication
	Token                  Type = 0x064 // Dashboard Auth
	OAuthCredential        Type = 0x065 // OAuth Client ID/Secret Pair
	OAuthAuthorizationCode Type = 0x066 // OAuth Authorization COde
	OAuthAccessToken       Type = 0x067 // OAuth Access Token

	// Things you can buy, and how you buy them
	Provider Type = 0x0C8
	Product  Type = 0x0C9
	Plan     Type = 0x0CA
	Region   Type = 0x0CB

	// Long-running actions for creating or modifying resources
	Operation Type = 0x12C
	Callback  Type = 0x12D

	// Provisioned resources and related
	Resource   Type = 0x190
	Credential Type = 0x191

	// Billing objects
	BillingProfile Type = 0x1F4

	Trial             Type = 0x1F5
	SubscriptionEvent Type = 0x1F6
	Invoice           Type = 0x1F7 // Charges for users
	InvoiceEvent      Type = 0x1F8 // record of payment or failure to pay

	// A copy of a SubscriptionEvent recorded in the provider's event stream
	ProviderSubscriptionEvent Type = 0x1F9
	Payout                    Type = 0x1FA // Payouts for providers
	PayoutEvent               Type = 0x1FB // record of payout of failure to payout
	PayoutProfile             Type = 0x1FC // Payout profile for providers

	// Values from 0xF00 to 0x1000 are reserved for Manifold private internal
	// only use.
	ManifoldInternalReserved Type = 0xF00

	// 13 filled bits would push the type into our version. If you reach this
	// point you're adding the 4097th type.
	TypeOverflow = 0x1000
)

All of our public types. They are explicitly given their hex values, as these should not change.

############################################################################ HOW TO ADD A NEW TYPE: Find the group that it fits in with. Add it there, with the next available number in sequence for the group.

If there is no group that fits, create a new group section. Create your new section allowing for 100 items in the previous section. ie 0x64 + the value of the first item in the previous section. This gives us room to add more items sequentially to each section.

If we run out of space to add a new 100 group block, then we can start filling in 50 group blocks from the start, and so on.

It is a lot of work, but it lets us keep everything neat and tidy! ############################################################################

func Decode

func Decode(upper, lower byte) Type

Decode decodes a Type from a byte pair

func (Type) Collection

func (t Type) Collection() string

Collection returns the name for a collection of these types

func (Type) Lower

func (t Type) Lower() byte

Lower returns the lower byte of the type

func (Type) Mutable

func (t Type) Mutable() bool

Mutable returns whether or not those type is mutable

func (Type) Name

func (t Type) Name() string

Name returns the name of a single instance of this type

func (Type) String

func (t Type) String() string

String returns the string representation of the primitive type

func (Type) Upper

func (t Type) Upper() byte

Upper returns the upper byte of the type

Jump to

Keyboard shortcuts

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