tools

package
v0.0.0-...-245f3ad Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CATALOGAPI = "oc-catalog"
View Source
var DATACENTERAPI = "oc-datacenter"

Bind the standard API name to the data type

View Source
var HTTPCallerInstance = &HTTPCaller{} // Singleton instance of the HTTPCaller
View Source
var NOAPI = ""
View Source
var PEERSAPI = "oc-peer"
View Source
var SHAREDAPI = "oc-shared"
View Source
var Str = [...]string{
	"invalid",
	"data_resource",
	"processing_resource",
	"storage_resource",
	"compute_resource",
	"workflow_resource",
	"workflow",
	"workflow_execution",
	"workspace",
	"resource_model",
	"peer",
	"collaborative_area",
	"rule",
	"booking",
	"workflow_history",
	"workspace_history",
}

Bind the standard data name to the data type

View Source
var UncatchedError = []error{} // Singleton instance of the api 500 error cache

* API is the Health Check API * it defines the health check methods

View Source
var WORKFLOWAPI = "oc-workflow"
View Source
var WORKSPACEAPI = "oc-workspace"

Functions

func FromInt

func FromInt(i int) string

func NewNATSCaller

func NewNATSCaller() *natsCaller

NewNATSCaller creates a new instance of the NATS Caller

Types

type API

type API struct{}

func (*API) CheckRemoteAPIs

func (a *API) CheckRemoteAPIs(apis []DataType) (State, map[string]string, error)

CheckRemoteAPIs checks the state of remote APIs from your proper OC

func (*API) CheckRemotePeer

func (a *API) CheckRemotePeer(url string) (State, map[string]int)

CheckRemotePeer checks the state of a remote peer

func (*API) Discovered

func (a *API) Discovered(infos []*beego.ControllerInfo)

func (*API) GetState

func (a *API) GetState() (State, int, error)

GetState returns the state of the API

func (*API) ListenRouter

func (a *API) ListenRouter(exec func(msg map[string]interface{}))

func (*API) SubscribeRouter

func (a *API) SubscribeRouter(infos []*beego.ControllerInfo)

type APIStatus

type APIStatus struct {
	Code     int               `json:"code"`     // Code is the status code, where 0 is ALIVE, 1 is REDUCED_SERVICE, 2 is UNPROCESSABLE_ENTITY, 3 is DB_FALLOUT, 4 is TEAPOT, 5 is DEAD
	State    string            `json:"state"`    // State is the state of the API (status shows as a string) (alive, reduced service, unprocessable entity, database fallout, some things boils in here, i'm probably a teapot, dead)
	Services map[string]string `json:"services"` // Services is the state of the services of the API (status shows as a string) (alive, reduced service, unprocessable entity, database fallout, some things boils in here, i'm probably a teapot, dead)
}

* APIStatus is the status of the API * it defines the state of the API * Code is the status code, where 0 is ALIVE, 1 is REDUCED_SERVICE, 2 is UNPROCESSABLE_ENTITY, 3 is DB_FALLOUT, 4 is TEAPOT, 5 is DEAD

type APIStatusResponse

type APIStatusResponse struct {
	Data  *APIStatus `json:"data"`
	Error string     `json:"error"`
}

APIStatusResponse is the response of the API status

type DataType

type DataType int
const (
	INVALID DataType = iota
	DATA_RESOURCE
	PROCESSING_RESOURCE
	STORAGE_RESOURCE
	COMPUTE_RESOURCE
	WORKFLOW_RESOURCE
	WORKFLOW
	WORKFLOW_EXECUTION
	WORKSPACE
	RESOURCE_MODEL
	PEER
	COLLABORATIVE_AREA
	RULE
	BOOKING
	WORKFLOW_HISTORY
	WORKSPACE_HISTORY
)

DataType - Enum for the different types of resources in db accessible from the outside

func (DataType) API

func (d DataType) API() string

func (DataType) EnumIndex

func (d DataType) EnumIndex() int

EnumIndex - Creating common behavior - give the type a EnumIndex functio

func (DataType) String

func (d DataType) String() string

type HTTPCaller

type HTTPCaller struct {
	URLS     map[DataType]map[METHOD]string // Map of the different methods and their urls
	Disabled bool                           // Disabled flag
}

func NewHTTPCaller

func NewHTTPCaller(urls map[DataType]map[METHOD]string) *HTTPCaller

NewHTTPCaller creates a new instance of the HTTP Caller

func (*HTTPCaller) CallDelete

func (caller *HTTPCaller) CallDelete(url string, subpath string) ([]byte, error)

CallPut calls the DELETE method on the HTTP server

func (*HTTPCaller) CallForm

func (caller *HTTPCaller) CallForm(method string, url string, subpath string,
	body url.Values, content_type string, fakeTLSTermination bool, cookies ...*http.Cookie) (*http.Response, error)

CallRaw calls the Raw method on the HTTP server

func (*HTTPCaller) CallGet

func (caller *HTTPCaller) CallGet(url string, subpath string, types ...string) ([]byte, error)

CallGet calls the GET method on the HTTP server

func (*HTTPCaller) CallPost

func (caller *HTTPCaller) CallPost(url string, subpath string, body map[string]interface{}, types ...string) ([]byte, error)

CallPost calls the POST method on the HTTP server

func (*HTTPCaller) CallPut

func (caller *HTTPCaller) CallPut(url string, subpath string, body map[string]interface{}) ([]byte, error)

CallPost calls the POST method on the HTTP server

func (*HTTPCaller) CallRaw

func (caller *HTTPCaller) CallRaw(method string, url string, subpath string,
	body map[string]interface{}, content_type string, fakeTLSTermination bool, cookies ...*http.Cookie) (*http.Response, error)

CallRaw calls the Raw method on the HTTP server

type METHOD

type METHOD int

HTTP Method Enum defines the different methods that can be used to interact with the HTTP server

const (
	GET METHOD = iota
	PUT
	POST
	DELETE

	STRICT_INTERNAL_GET
	STRICT_INTERNAL_PUT
	STRICT_INTERNAL_POST
	STRICT_INTERNAL_DELETE
)

func ToMethod

func ToMethod(str string) METHOD

ToMethod returns the method from a string

func (METHOD) EnumIndex

func (m METHOD) EnumIndex() int

EnumIndex returns the index of the enum

func (METHOD) String

func (m METHOD) String() string

String returns the string of the enum

type NATSMethod

type NATSMethod int

NATS Method Enum defines the different methods that can be used to interact with the NATS server

const (
	REMOVE NATSMethod = iota
	CREATE
	DISCOVERY
)

func NameToMethod

func NameToMethod(name string) NATSMethod

NameToMethod returns the NATSMethod enum value from a string

func (NATSMethod) GenerateKey

func (d NATSMethod) GenerateKey(name string) string

GenerateKey generates a key for the NATSMethod usefull for standard key based on data name & method

func (NATSMethod) String

func (d NATSMethod) String() string

String returns the string of the enum

type State

type State int
const (
	ALIVE                State = iota
	REDUCED_SERVICE            // occurs when some services are down
	UNPROCESSABLE_ENTITY       // occurs when the database is up but the collections are not
	DB_FALLOUT                 // occurs when the database is down
	TEAPOT                     // well some things boils in here, i'm probably a teapot, occurs when uncatched errors are present (it's fun)
	DEAD                       // occurs when the peer is dead
)

State is an enum that defines the state of the API

func ToState

func ToState(str string) State

ToState returns the state from a string

func (State) EnumIndex

func (s State) EnumIndex() int

EnumIndex returns the index of the enum

func (State) String

func (s State) String() string

String returns the string of the enum

Jump to

Keyboard shortcuts

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