usecases

package
v0.0.0-...-4e5abf6 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 24 Imported by: 8

README

mbaigo use cases package

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

  • Configuration: creates a new configuration file if it does not exist and later updates the system with deployment information.
  • Authorization: creates a certificate sigining request (CSR) to be sent to the CA.
  • Registration: registers all services of a system with the lead Service Registrar and keeps it continuously updated.
  • Servers & Requests: starts the severs for each protocol and directs requests.
  • Provision:

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ACServices

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

ACServices handles the http requestfor the cost of a service

func Configure

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

Configure read the system configuration JSON file to get the deployment details. If the file is missing, it generates a systemconfig 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 FillDiscoveredServices

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

FillDiscoveredServices returrns 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 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 HTTPProcessGetRequest

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

HTTPProcessSetRequest processes a Get request

func HTTPProcessSetRequest

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

HTTPProcessSetRequest processes a SET request

func Pack

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

Pack serializes a form to a byte array for payolad shipment with serializaton format (sf) request

func RegisterServices

func RegisterServices(sys *components.System)

RegisterServices keeps trach 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 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 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 ServQustForms

func ServQustForms() []string

ServRegForms returns the list of forms that the service registration handles

func ServRegReqExtract

func ServRegReqExtract(bodyBytes []byte) (rec forms.ServiceRecord_v1, err error)

servRegReqExtract determines the corrrecet forrm in to which the raw json data is used to update the service based on entry into the data base [Receving @ ServiceRegistry]

func ServRegRespFillIn

func ServRegRespFillIn(rec forms.ServiceRecord_v1, version string) (payload []byte, err error)

ServRegRespFillIn returrns a json data byte array with the data of the service to be registered in the form of choice [Sending @ ServiceRegistry]

func ServiceRegistrationFormsList

func ServiceRegistrationFormsList() []string

ServiceRegistrationFormsList returns the list of foms that the service registration handles

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) (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) (err error)

SetoutServers setup the http and https servers and starts them

func Unpack

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

Unpack function to deserialize data into appropriate form structs

Types

type ConfigFile2Sys

type ConfigFile2Sys struct {
	CName string `json:"systemname"`

	CServices  []components.Service    `json:"services"`
	Protocols  map[string]int          `json:"protocolsNports"`
	PKIdetails pkix.Name               `json:"distinguishedName"`
	CCoreS     []components.CoreSystem `json:"coreSystems"`
	// contains filtered or unexported fields
}

ConfigFile2Sys is used to extact out the information of the systemconfig.json file Since it does not know about the details of the Thing, it does not unmarsahll this information

type Sys2ConfigFile

type Sys2ConfigFile struct {
	CName      string                  `json:"systemname"`
	UAsset     []components.UnitAsset  `json:"unit_assets"`
	CServices  []components.Service    `json:"services"`
	Protocols  map[string]int          `json:"protocolsNports"`
	PKIdetails pkix.Name               `json:"distinguishedName"`
	CCoreS     []components.CoreSystem `json:"coreSystems"`
}

Sys2ConfigFile is the stuct used to prepare the systemconfig.json file

Jump to

Keyboard shortcuts

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