malgomaj

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package malgomaj provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.

Package malgomaj provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.

Index

Constants

View Source
const (
	BasicAuthScopes = "BasicAuth.Scopes"
)

Variables

View Source
var AllowedBaseModules = []string{
	"base64",
	"enum",

	"hex",
	"json",
	"math",
	"rand",
	"text",
	"times",
}
View Source
var ExtraModules = map[string]map[string]tengo.Object{
	"fmt":  fmtModule,
	"http": httpModule,
	"log":  logModule,
	"cgi":  nil,
}

Functions

func GetOpenAPIFile

func GetOpenAPIFile() ([]byte, error)

func GetSwagger

func GetSwagger() (swagger *openapi3.Swagger, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func ProgramCacheGetLoad

func ProgramCacheGetLoad() int64

func SetCacheTimeout

func SetCacheTimeout(seconds int)

Types

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL     string
	BaseRouter  chi.Router
	Middlewares []MiddlewareFunc
}

type CreateTaskJSONBodyLanguage

type CreateTaskJSONBodyLanguage string

CreateTaskJSONBodyLanguage defines parameters for CreateTask.

type CreateTaskJSONBody_Http_Headers

type CreateTaskJSONBody_Http_Headers struct {
	AdditionalProperties map[string]string `json:"-"`
}

CreateTaskJSONBody_Http_Headers defines parameters for CreateTask.

func (CreateTaskJSONBody_Http_Headers) Get

func (a CreateTaskJSONBody_Http_Headers) Get(fieldName string) (value string, found bool)

Getter for additional properties for CreateTaskJSONBody_Http_Headers. Returns the specified element and whether it was found

func (CreateTaskJSONBody_Http_Headers) MarshalJSON

func (a CreateTaskJSONBody_Http_Headers) MarshalJSON() ([]byte, error)

Override default JSON handling for CreateTaskJSONBody_Http_Headers to handle AdditionalProperties

func (*CreateTaskJSONBody_Http_Headers) Set

func (a *CreateTaskJSONBody_Http_Headers) Set(fieldName string, value string)

Setter for additional properties for CreateTaskJSONBody_Http_Headers

func (*CreateTaskJSONBody_Http_Headers) UnmarshalJSON

func (a *CreateTaskJSONBody_Http_Headers) UnmarshalJSON(b []byte) error

Override default JSON handling for CreateTaskJSONBody_Http_Headers to handle AdditionalProperties

type CreateTaskJSONRequestBody

type CreateTaskJSONRequestBody NewTask

CreateTaskJSONRequestBody defines body for CreateTask for application/json ContentType.

type Error

type Error struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

type MiddlewareFunc

type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc

type NewTask

type NewTask struct {
	Deadline int    `json:"deadline"`
	Domain   string `json:"domain"`

	// Optional. When in use the task is executed as a HTTP procedure.
	Http *struct {
		Body    []byte               `json:"body"`
		Headers NewTask_Http_Headers `json:"headers"`
	} `json:"http,omitempty"`
	Language    NewTaskLanguage `json:"language"`
	ProgramUuid string          `json:"program_uuid"`
	SourceCode  []byte          `json:"source_code"`
}

NewTask defines model for NewTask.

func (*NewTask) GetId

func (t *NewTask) GetId() string

Return the Id used by the Cache

type NewTaskHttp

type NewTaskHttp struct {
	Body    []byte               `json:"body"`
	Headers NewTask_Http_Headers `json:"headers"`
}

type NewTaskLanguage

type NewTaskLanguage string
const (
	NewTaskLanguageTengo NewTaskLanguage = "tengo"
)

Defines values for NewTaskLanguage.

type NewTask_Http_Headers

type NewTask_Http_Headers map[string]string

type NewTask_Libraries

type NewTask_Libraries map[string][]byte

type Program

type Program interface {
	Equals(b Program) bool
	Compile(context.Context) error
	Run(context.Context) error
	RunWithHTTP(context.Context, http.ResponseWriter, *http.Request) error
	Modules() []string
	Language() string

	Id() string
	Deadline() time.Duration
	Checksum() [16]byte // MD5
}

func NewProgram

func NewProgram(domain string, id string, language string, deadline time.Duration, sourceCode []byte) (Program, error)

type ProgramCache

type ProgramCache struct {
	// contains filtered or unexported fields
}

type ProgramCacheItem

type ProgramCacheItem struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func ProgramCacheAdd

func ProgramCacheAdd(p Program) *ProgramCacheItem

func ProgramCacheGet

func ProgramCacheGet(id string) *ProgramCacheItem

func (*ProgramCacheItem) Expires

func (p *ProgramCacheItem) Expires() time.Time

func (*ProgramCacheItem) GetId

func (p *ProgramCacheItem) GetId() string

func (*ProgramCacheItem) Start

func (p *ProgramCacheItem) Start()

func (*ProgramCacheItem) Stop

func (p *ProgramCacheItem) Stop()

type Response

type Response struct {
	StatusCode int
	Body       []byte
}

type RestApi

type RestApi struct{}

func New

func New() *RestApi

func (*RestApi) CreateTask

func (ra *RestApi) CreateTask(w http.ResponseWriter, r *http.Request)

func (*RestApi) GetStatus

func (ra *RestApi) GetStatus(w http.ResponseWriter, r *http.Request)

type ServerInterface

type ServerInterface interface {
	// Get worker status
	// (GET /v1/status)
	GetStatus(w http.ResponseWriter, r *http.Request)
	// Add a new Task
	// (POST /v1/tasks)
	CreateTask(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateTask

func (siw *ServerInterfaceWrapper) CreateTask(w http.ResponseWriter, r *http.Request)

CreateTask operation middleware

func (*ServerInterfaceWrapper) GetStatus

func (siw *ServerInterfaceWrapper) GetStatus(w http.ResponseWriter, r *http.Request)

GetStatus operation middleware

type Status

type Status struct {

	// The current load (aggregated deadlines)
	Load int64 `json:"load"`
}

Status defines model for Status.

type TengoProgram

type TengoProgram struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTengoProgram

func NewTengoProgram(domain string, id string, deadline time.Duration, sourceCode []byte) *TengoProgram

func (*TengoProgram) AllImports

func (p *TengoProgram) AllImports() []string

func (*TengoProgram) Checksum

func (p *TengoProgram) Checksum() [16]byte

func (*TengoProgram) Compile

func (p *TengoProgram) Compile(ctx context.Context) (err error)

func (*TengoProgram) Deadline

func (p *TengoProgram) Deadline() time.Duration

func (*TengoProgram) Equals

func (p *TengoProgram) Equals(b Program) bool

func (*TengoProgram) Id

func (p *TengoProgram) Id() string

func (*TengoProgram) IsCGI

func (p *TengoProgram) IsCGI() bool

func (*TengoProgram) Language

func (p *TengoProgram) Language() string

func (*TengoProgram) Modules

func (p *TengoProgram) Modules() []string

func (*TengoProgram) Run

func (p *TengoProgram) Run(ctx context.Context) error

func (*TengoProgram) RunWithHTTP

func (p *TengoProgram) RunWithHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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