usecases

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 28 Imported by: 18

README

mbaigo use cases package

Package "usecases" addresses system behaviors and actions in given use cases such as configuration, registration, authentication, orchestration, ...

  • authentication: creates a private key and a certificate signing request (CSR) to be sent to the CA. It is not yet going authentication, just "certification"
  • configuration: creates a new configuration file if it does not exist and later updates the system with deployment information
  • consumption: makes requests to providers, and invokes serviceDiscovery if the service URL is unknown
  • cost: handles service costs
  • kgaphing: generates the knowledge graph of the system
  • packing: marshals and un-marshals forms which all communications use
  • provision: responding so consumers'requests
  • registration: registers all services of a system with the lead Service Registrar and keeps it continuously updated.
  • service discovery: interaction with the Orchestrator to obtain all service URL based on description
  • subscription: based on the Observer pattern, keep track of subscribers

Documentation

Overview

Package "usecases" addresses system actions in given use cases such as configuration, registration, authentication, orchestration, ...

Index

Constants

This section is empty.

Variables

View Source
var ErrNewConfig = errors.New("new config file was created")

Functions

func ACServices

func ACServices(w http.ResponseWriter, r *http.Request, ua *components.UnitAsset, serviceP string)

ACServices handles the http request for the cost of a service

func Configure

func Configure(sys *components.System) ([]json.RawMessage, error)

Configure reads the system configuration JSON file to get the deployment details. If the file is missing, it generates a default systemconfig.json file and shuts down the system

func ExtractDiscoveryForm

func ExtractDiscoveryForm(bodyBytes []byte) (sLoc forms.ServicePoint_v1, err error)

ExtractDiscoveryForm is used by the Orchestrator and the authorized consumer system

func ExtractQuestForm

func ExtractQuestForm(bodyBytes []byte) (rec forms.ServiceQuest_v1, err error)

ExtractQuestForm is used by the Service Registrar and Orchestrator when they receive a service query from a consumer system

func FCServices

func FCServices(w http.ResponseWriter, r *http.Request, ua *components.UnitAsset, serviceP string)

FCServices handles the carbon footprint service requests

func FillDiscoveredServices

func FillDiscoveredServices(dsList []forms.ServiceRecord_v1, version string) (f forms.Form, err error)

FillDiscoveredServices returns a json data byte array with a slice of matching services (e.g., Service Registrar)

func FillQuestForm

func FillQuestForm(sys *components.System, res components.UnitAsset, sDef, protocol string) forms.ServiceQuest_v1

FillQuestForm described the sought service (e.g., RemoteSignal)

func GetActivitiesCarbon

func GetActivitiesCarbon(serv *components.Service) (payload []byte, err error)

GetActivitiesCarbon retrieves the service carbon footprint

func GetActivitiesCost

func GetActivitiesCost(serv *components.Service) (payload []byte, err error)

func GetState

func GetState(cer *components.Cervice, sys *components.System) (f forms.Form, err error)

GetState request the current state of a unit asset (via the asset's service)

func GetStates

func GetStates(cer *components.Cervice, sys *components.System) (f []forms.Form, err []error)

GetStates requests the current state of certain services of a unit asset depending on requested definition and/or details

func HTTPProcessGetRequest

func HTTPProcessGetRequest(w http.ResponseWriter, r *http.Request, f forms.Form)

HTTPProcessSetRequest processes a Get request TODO: this function should really return an error too and behave like everyone else. And causing http.Errors is an ugly side effect.

func HTTPProcessSetRequest

func HTTPProcessSetRequest(w http.ResponseWriter, req *http.Request) (sig forms.SignalA_v1a, err error)

HTTPProcessSetRequest processes a SET request

func IsCamelCase

func IsCamelCase(s string) bool

IsCamelCase returns true if the string starts with a lowercase letter.

func IsFirstLetterLower

func IsFirstLetterLower(s string) bool

IsFirstLetterLower returns true if the first rune is lowercase.

func IsFirstLetterUpper

func IsFirstLetterUpper(s string) bool

IsFirstLetterUpper returns true if the first rune is uppercase.

func IsPascalCase

func IsPascalCase(s string) bool

IsPascalCase returns true if the string starts with an uppercase letter.

func KGraphing

func KGraphing(w http.ResponseWriter, req *http.Request, sys *components.System)

function KGraphing provides a semantic model of a system running on a host and exposing the functionality of asset

func Log

func Log(sys *components.System, lvl forms.MessageLevel, msg string, args ...any)

func LogDebug

func LogDebug(sys *components.System, msg string, args ...any)

func LogError

func LogError(sys *components.System, msg string, args ...any)

func LogInfo

func LogInfo(sys *components.System, msg string, args ...any)

func LogWarn

func LogWarn(sys *components.System, msg string, args ...any)

func MakeServiceMap

func MakeServiceMap(services []components.Service) map[string]*components.Service

MakeServiceMap() creates a map of services from a slice of services The map is indexed by the service subpath

func Pack

func Pack(f forms.Form, contentType string) (data []byte, err error)

Pack serializes a form to a byte array for payload shipment with serialization format (sf) request

func RegisterMessenger

func RegisterMessenger(resp http.ResponseWriter, req *http.Request, sys *components.System)

func RegisterServices

func RegisterServices(sys *components.System)

RegisterServices keeps track of the leading Service Registrar and keeps all services registered

func RequestCertificate

func RequestCertificate(sys *components.System)

RequestCertificate generates the system's public key and a certificate signing request to be sent to the CA

func ResHateoas

func ResHateoas(w http.ResponseWriter, req *http.Request, ua components.UnitAsset, sys components.System)

ResHateoas provides information about the unit asset(s) and each service and is accessed via the system's web server

func ResourceHandler

func ResourceHandler(sys *components.System, w http.ResponseWriter, r *http.Request)

ResourceHandler break up the request in parts and finds out what is requested as in http://192.168.1.4:8700/photographer/picam/files/image_20240325-211555.jpg where photographer is part[1], picam is part[2](with len==3), files is part[3] (with len==4)

func SModeling

func SModeling(w http.ResponseWriter, req *http.Request, sys *components.System)

SModeling writes a SysML v2 textual model of the system to the HTTP response.

func Search4MultipleServices

func Search4MultipleServices(cer *components.Cervice, sys *components.System) (err error)

func Search4Service

func Search4Service(qf forms.ServiceQuest_v1, sys *components.System) (servLocation forms.ServicePoint_v1, err error)

Search4Service requests from the core systems the address of resources's services that meet the need

func Search4Services

func Search4Services(cer *components.Cervice, sys *components.System) (err error)

Search4Services requests from the core systems the address of resources' services that meet the need

func ServQuestForms

func ServQuestForms() []string

ServRegForms returns the list of forms that the service registration handles

func ServiceHateoas

func ServiceHateoas(w http.ResponseWriter, req *http.Request, serv components.Service, sys components.System)

ServiceHateoas provides information about the service and is accessed via the system's web server

func ServiceRegistrationFormsList

func ServiceRegistrationFormsList() []string

ServiceRegistrationFormsList returns the list of forms that the service registration handles

func SetActivitiesCarbon

func SetActivitiesCarbon(serv *components.Service, bodyBytes []byte) (err error)

SetActivitiesCarbon sets the service carbon footprint from the request body

func SetActivitiesCost

func SetActivitiesCost(serv *components.Service, bodyBytes []byte) (err error)

SetActivitiesCost updates the service cost

func SetState

func SetState(cer *components.Cervice, sys *components.System, bodyBytes []byte) (f forms.Form, err error)

SetState puts a request to change the state of a unit asset (via the asset's service)

func SetoutServers

func SetoutServers(sys *components.System) error

SetoutServers setups the http and https servers and starts them

func SysHateoas

func SysHateoas(w http.ResponseWriter, req *http.Request, sys components.System)

System Documentation (based on HATEOAS) provides an initial documentation on the system's web server of with hyperlinks to the services for browsers HATEOAS is the acronym for Hypermedia as the Engine of Application State, using hyperlinks to navigate the API

func ToCamel

func ToCamel(s string) string

ToCamel converts PascalCase to camelCase.

func ToPascal

func ToPascal(s string) string

ToPascal converts camelCase to PascalCase.

func Unpack

func Unpack(data []byte, contentType string) (forms.Form, error)

Unpack function to deserialize data into appropriate form structs

Types

type ConfigurableAsset

type ConfigurableAsset struct {
	Name     string               `json:"name"`
	Mission  string               `json:"mission,omitempty"`
	Details  map[string][]string  `json:"details"`
	Services []components.Service `json:"services"`
	Traits   []json.RawMessage    `json:"traits"`
}

configurableAsset is a struct that contains the name of the asset and its configurable details and services

Jump to

Keyboard shortcuts

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