juvuln

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 juvuln provides primitives to interact with the openapi HTTP API.

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

Package juvuln 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

This section is empty.

Functions

func GetOpenAPIFile

func GetOpenAPIFile() ([]byte, error)

Get the OpenAPI file

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 UpdateProgramCache

func UpdateProgramCache() error

Update the program listing by queries each DB for content

Types

type BadGateway

type BadGateway Error

BadGateway defines model for BadGateway.

type ChiServerOptions

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

type DomainPathParam

type DomainPathParam string

DomainPathParam defines model for domainPathParam.

type DomainQueryParam

type DomainQueryParam string

DomainQueryParam defines model for domainQueryParam.

type Error

type Error struct {

	// Error code
	Code int `json:"code"`

	// Error message
	Message string `json:"message"`
}

Error defines model for Error.

type GetModuleAtRevisionParams

type GetModuleAtRevisionParams struct {

	// A domain
	Domain DomainQueryParam `json:"domain"`

	// The module name
	Module ModuleParam `json:"module"`

	// The language of the module
	Language LanguageParam `json:"language"`

	// The module revision. The keyword 'latest' will return the latest revision.
	Revision RevisionParam `json:"revision"`
}

GetModuleAtRevisionParams defines parameters for GetModuleAtRevision.

type InternalServerError

type InternalServerError Error

InternalServerError defines model for InternalServerError.

type LanguageParam

type LanguageParam string

LanguageParam defines model for languageParam.

type MiddlewareFunc

type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc

type ModuleParam

type ModuleParam string

ModuleParam defines model for moduleParam.

type NewSubscriber

type NewSubscriber struct {

	// On the format [userinfo@]host[:port].
	Authority string `json:"authority"`

	// A list of supported languages.
	Languages []string            `json:"languages"`
	Scheme    NewSubscriberScheme `json:"scheme"`
	Uuid      string              `json:"uuid"`
}

NewSubscriber defines model for NewSubscriber.

type NewSubscriberScheme

type NewSubscriberScheme SubscriberScheme

type NotFound

type NotFound Error

NotFound defines model for NotFound.

type ProgramCache

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

func (*ProgramCache) Add

func (p *ProgramCache) Add(obj *ProgramRevision)

func (*ProgramCache) Begin

func (p *ProgramCache) Begin()

func (*ProgramCache) Commit

func (p *ProgramCache) Commit()

func (*ProgramCache) GetModule

func (p *ProgramCache) GetModule(domain, name string, revision int32) (*ProgramRevision, error)

type ProgramRevision

type ProgramRevision struct {
	Domain      string
	Name        string
	ProgramUuid uuid.UUID
	Type        string
	Schedule    string
	Deadline    int32
	Language    string
	Revision    int32
	Code        []byte
	Checksum    string
	// contains filtered or unexported fields
}

func NewProgramRevision

func NewProgramRevision(domain string, name string, programUUID uuid.UUID, ptype string, schedule string,
	deadline int32, language string, revision int32, code []byte, checksum string) *ProgramRevision

func (*ProgramRevision) Equals

func (p *ProgramRevision) Equals(b *ProgramRevision) bool

func (*ProgramRevision) Execute

func (p *ProgramRevision) Execute() error

func (*ProgramRevision) GetId

func (p *ProgramRevision) GetId() string

func (*ProgramRevision) Run added in v0.1.2

func (p *ProgramRevision) Run()

func (*ProgramRevision) Start

func (p *ProgramRevision) Start()

func (*ProgramRevision) Stop

func (p *ProgramRevision) Stop()

type RestApi

type RestApi struct{}

Main struct for the RestApi implementation

func New

func New() *RestApi

Create a new RestApi instance

func (*RestApi) CheckWorker

func (ra *RestApi) CheckWorker(w http.ResponseWriter, r *http.Request, id UuidParam)

Check registration

func (*RestApi) ForwardWebhook

func (ra *RestApi) ForwardWebhook(w http.ResponseWriter, r *http.Request, dom DomainPathParam, id UuidParam)

Forward a call to a webhook program

func (*RestApi) GetModuleAtRevision

func (ra *RestApi) GetModuleAtRevision(w http.ResponseWriter, r *http.Request, p GetModuleAtRevisionParams)

Get the code for a program module

func (*RestApi) WorkerLoadUpdate

func (ra *RestApi) WorkerLoadUpdate(w http.ResponseWriter, r *http.Request, id UuidParam)

Report the current load

func (*RestApi) WorkerSubscribe

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

Self registration subscription endpoint

func (*RestApi) WorkerUnsubscribe

func (ra *RestApi) WorkerUnsubscribe(w http.ResponseWriter, r *http.Request, id UuidParam)

Self un-registration subscription endpoint

type RevisionParam

type RevisionParam string

RevisionParam defines model for revisionParam.

type ServerInterface

type ServerInterface interface {
	// Get module
	// (GET /v1/library)
	GetModuleAtRevision(w http.ResponseWriter, r *http.Request, params GetModuleAtRevisionParams)
	// Subscribe as a worker.
	// (POST /v1/subscribers)
	WorkerSubscribe(w http.ResponseWriter, r *http.Request)
	// Unsubscribe as a worker
	// (DELETE /v1/subscribers/{uuid})
	WorkerUnsubscribe(w http.ResponseWriter, r *http.Request, uuid UuidParam)
	// Check if subscriber has been added
	// (GET /v1/subscribers/{uuid})
	CheckWorker(w http.ResponseWriter, r *http.Request, uuid UuidParam)
	// Update Load Data
	// (PUT /v1/subscribers/{uuid}/load)
	WorkerLoadUpdate(w http.ResponseWriter, r *http.Request, uuid UuidParam)
	// Proxy interface for webhooks
	// (POST /v1/webhooks/{domain}/{uuid})
	ForwardWebhook(w http.ResponseWriter, r *http.Request, domain DomainPathParam, uuid UuidParam)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CheckWorker

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

CheckWorker operation middleware

func (*ServerInterfaceWrapper) ForwardWebhook

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

ForwardWebhook operation middleware

func (*ServerInterfaceWrapper) GetModuleAtRevision

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

GetModuleAtRevision operation middleware

func (*ServerInterfaceWrapper) WorkerLoadUpdate

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

WorkerLoadUpdate operation middleware

func (*ServerInterfaceWrapper) WorkerSubscribe

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

WorkerSubscribe operation middleware

func (*ServerInterfaceWrapper) WorkerUnsubscribe

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

WorkerUnsubscribe operation middleware

type SubscriberScheme

type SubscriberScheme string
const (
	SubscriberSchemeHttp SubscriberScheme = "http"

	SubscriberSchemeHttps SubscriberScheme = "https"
)

Defines values for SubscriberScheme.

type Unauthorized

type Unauthorized Error

Unauthorized defines model for Unauthorized.

type UpdateLoad

type UpdateLoad struct {
	Load int64 `json:"load"`
}

UpdateLoad defines model for UpdateLoad.

type UuidParam

type UuidParam string

UuidParam defines model for uuidParam.

type Worker

type Worker struct {
	sync.Mutex

	Id        string
	URI       string
	Languages []string
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(id, uri string, langs []string, timeout time.Duration) *Worker

func (*Worker) Alive

func (w *Worker) Alive() bool

func (*Worker) GetLoad

func (w *Worker) GetLoad() uint64

func (*Worker) SetLoad

func (w *Worker) SetLoad(l uint64)

type WorkerLoadUpdateJSONRequestBody

type WorkerLoadUpdateJSONRequestBody UpdateLoad

WorkerLoadUpdateJSONRequestBody defines body for WorkerLoadUpdate for application/json ContentType.

type WorkerSubscribeJSONBodyScheme

type WorkerSubscribeJSONBodyScheme string

WorkerSubscribeJSONBodyScheme defines parameters for WorkerSubscribe.

type WorkerSubscribeJSONRequestBody

type WorkerSubscribeJSONRequestBody NewSubscriber

WorkerSubscribeJSONRequestBody defines body for WorkerSubscribe for application/json ContentType.

type WorkerTask

type WorkerTask struct {
	Language    string    `json:"language"`
	Deadline    int       `json:"deadline"`
	Domain      string    `json:"domain"`
	ProgramUuid uuid.UUID `json:"program_uuid"`
	SourceCode  string    `json:"source_code"`
}

Jump to

Keyboard shortcuts

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