Documentation ¶
Index ¶
- Constants
- func DeregisterOneAndOnlyType(typeIdentifier TypeIdentifier)
- func FindTypeServiceUrl(typeIdentifier TypeIdentifier) (string, error)
- func GetUserIdFromGinContext(c *gin.Context) string
- func RegisterOneAndOnlyType(typeIdentifier TypeIdentifier, port int)
- type ConsulClient
- type ThingIdentifier
- type ThingMetadata
- type TypeIdentifier
- type UID
Constants ¶
const USER_ID_ADMIN = "_admin_"
magic user id used for admin access
const USER_ID_INTERNAL = "_internal_"
magic user id used for internal access, i.e. one type/service accessing another service
Variables ¶
This section is empty.
Functions ¶
func DeregisterOneAndOnlyType ¶
func DeregisterOneAndOnlyType(typeIdentifier TypeIdentifier)
func FindTypeServiceUrl ¶
func FindTypeServiceUrl(typeIdentifier TypeIdentifier) (string, error)
func GetUserIdFromGinContext ¶
function to get the HTTP header "X-User-Id" from the gin context
func RegisterOneAndOnlyType ¶
func RegisterOneAndOnlyType(typeIdentifier TypeIdentifier, port int)
Types ¶
type ConsulClient ¶
heavily inspired by https://blog.devgenius.io/tooling-go-microservices-with-consul-service-discovery-and-kv-store-2c52bcdf4fd4
func NewClient ¶
func NewClient(addr string) (*ConsulClient, error)
func (*ConsulClient) DeregisterType ¶
func (c *ConsulClient) DeregisterType(typeIdentifier TypeIdentifier) error
the following function deregisters the type/service from consul
func (*ConsulClient) FindTypeServiceUrl ¶
func (c *ConsulClient) FindTypeServiceUrl(typeIdentifier TypeIdentifier) (string, error)
find a service based on the type identifier in ConsulClient
func (*ConsulClient) RegisterType ¶
func (c *ConsulClient) RegisterType(typeIdentifier TypeIdentifier, port int) error
type ThingIdentifier ¶
type ThingIdentifier struct { Group string `json:"group,omitempty"` Type string `json:"type,omitempty"` UID UID `json:"uid,omitempty"` }
identifier for a specific single thing, e.g. group=sammeles.herzog.fyi, type=postcard, uid=abc123
type ThingMetadata ¶
type ThingMetadata struct { UID UID `json:"uid,omitempty"` // human-readable name of the thing (can contain spaces etc. as it is not used for identification) Name string `json:"name,omitempty"` Generation int64 `json:"generation,omitempty"` // reference to the direct parent (sub-) thing. // this is empty for root things. ParentRef string `json:"parentRef,omitempty"` CreationTimestamp time.Time `json:"creationTimestamp,omitempty"` UpdateTimestamp time.Time `json:"updateTimestamp,omitempty"` // collections that this (sub) thing belongs to. // for sub-things this will be synced eventually with the collections of the root thing (eventual consistency) Collections []UID `json:"collections,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` }
metadata for every (sub) thing, heavily inspired by https://pkg.go.dev/golang.org/x/build/kubernetes/api#ObjectMeta
type TypeIdentifier ¶
type TypeIdentifier struct { // a group is a domain name, e.g. herzog.fyi Group string `json:"id"` // the type of the thing, e.g. postcard. // should be short (often only one word) and not contain spaces or special characters besides _ and - Type string `json:"type"` // the schema version of the thing, e.g. 1. // the version is monotonically increasing and signals major changes to the type, possibly breaking backwards compatibility SchemaVersion int64 `json:"schemaVersion"` }
identifier for types of things. e.g. group=herzog.fyi, type=postcard, schemaVersion=1