enhancementservices

package
v0.0.0-...-6aee27a Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllWorkers

func AllWorkers() []string

AllWorkers is an effective constant representing all possible workers (not deleted)

func BuildTestLambdaWorker

func BuildTestLambdaWorker() awsConfigV1Worker

BuildTestLambdaWorker provides a way to conduct unit tests. This function creates a canned worker suitable for immediate use. Not intended for regular use

func BuildTestLambdaWorkerWithName

func BuildTestLambdaWorkerWithName(name string) awsConfigV1Worker

BuildTestLambdaWorkerWithName provides a way to conduct unit tests. This function creates a canned worker suitable for immediate use, of the provided name. Not intended for regular use

func BuildTestWebWorker

func BuildTestWebWorker() webConfigV1Worker

func MkRIEURL

func MkRIEURL(lambdaName string) string

func SendEvidenceCreatedEvent

func SendEvidenceCreatedEvent(db *database.Connection, reqLogger logging.Logger, operationID int64, evidenceUUIDs []string, workerNames []string) error

SendEvidenceCreatedEvent starts a specified set of workers for a specified set of evidenceUUIDs Note that this process kicks off a number of goroutines.

func SendServiceWorkerEvent

func SendServiceWorkerEvent(db *database.Connection, input SendServiceWorkerEventInput)

func SetNotifyWorkersRunForTest

func SetNotifyWorkersRunForTest(notifier chan<- bool)

func SetTestLambdaClient

func SetTestLambdaClient(client LambdaInvokableClient)

SetTestLambdaClient provides a way to conduct unit tests. Not intended for regular use

func SetWebRequestFunctionForWorker

func SetWebRequestFunctionForWorker(workerName string, fn *RequestFn)

Types

type AWSConfigV1

type AWSConfigV1 struct {
	BasicServiceWorkerConfig
	LambdaName string `json:"lambdaName"`
	AsyncFn    bool   `json:"asyncFunction"`
}

type BasicServiceWorkerConfig

type BasicServiceWorkerConfig struct {
	Type    string `json:"type"`
	Version int64  `json:"version"`
}

type ExpandedNewEvidencePayload

type ExpandedNewEvidencePayload struct {
	NewEvidencePayload
	EvidenceID int64 `db:"id"`
}

func BatchBuildNewEvidencePayload

func BatchBuildNewEvidencePayload(ctx context.Context, db database.ConnectionProxy, operationID int64, evidenceUUIDs []string) ([]ExpandedNewEvidencePayload, error)

BatchBuildNewEvidencePayload creates a set of payloads for the given operation and evidence uuids. This function provides convenience over the alternatives: BatchBuildNewEvidencePayloadFromUUIDs and BatchBuildNewEvidencePayloadForAllEvidence. Note that if no evidenceUUIDs are provided, then all evidence is chosen for the indicated operation.

func BatchBuildNewEvidencePayloadForAllEvidence

func BatchBuildNewEvidencePayloadForAllEvidence(ctx context.Context, db database.ConnectionProxy, operationID int64) ([]ExpandedNewEvidencePayload, error)

BatchBuildNewEvidencePayloadForAllEvidence creates a set of payloads, ordered by evidence ID, for all evidence in an operation. Also see BatchBuildNewEvidencePayload, which allows for specifying a subset of evidence uuids

func BatchBuildNewEvidencePayloadFromUUIDs

func BatchBuildNewEvidencePayloadFromUUIDs(ctx context.Context, db database.ConnectionProxy, operationID int64, evidenceUUIDs []string) ([]ExpandedNewEvidencePayload, error)

BatchBuildNewEvidencePayloadFromUUIDs creates a set of payloads, ordered by evidence ID, for the given operationID and evidenceUUIDs. If the list of uuids is empty, then _no payloads will be returned_. Also see BatchBuildNewEvidencePayload, which allows for getting all evidence if no uuids are specified

type LambdaInvokableClient

type LambdaInvokableClient interface {
	// Invoke(input *lambda.InvokeInput) (*lambda.InvokeOutput, error)
	Invoke(ctx context.Context, params *lambda.InvokeInput, optFns ...func(*lambda.Options)) (*lambda.InvokeOutput, error)
}

func NewTestRIELambdaClient

func NewTestRIELambdaClient(fn RequestFn) LambdaInvokableClient

NewTestRIELambdaClient creates an instance of LambdaInvokableClient that can be used for unit testing

type LambdaRIEClient

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

func (LambdaRIEClient) Invoke

func (l LambdaRIEClient) Invoke(ctx context.Context, input *lambda.InvokeInput, optFns ...func(*lambda.Options)) (*lambda.InvokeOutput, error)

Invoke mimics the aws Lambda function of the same name. This is useful for development testing without incurring AWS fees

type LambdaResponse

type LambdaResponse struct {
	StatusCode int    `json:"statusCode"`
	Body       string `json:"body"`
}

type NewEvidencePayload

type NewEvidencePayload struct {
	Type            string              `json:"type" db:"type"`
	EvidenceUUID    string              `json:"evidenceUuid"  db:"uuid"`
	OperationSlug   string              `json:"operationSlug" db:"operation_slug"`
	ContentType     string              `json:"contentType"   db:"content_type"`
	GlobalVariables []dtos.GlobalVar    `json:"globalVariables"`
	OperationVars   []dtos.OperationVar `json:"operationVariables"`
}

type ProcessResponse

type ProcessResponse struct {
	Action  string  `json:"action"`  // Rejected | Deferred | Processed | Error
	Content *string `json:"content"` // Error => reason, Processed => Result
}

type RequestFn

type RequestFn = func(method, url string, body io.Reader, updateRequest helpers.ModifyReqFunc) (*http.Response, error)

type SendServiceWorkerEventInput

type SendServiceWorkerEventInput struct {
	Logger      logging.Logger
	WorkerNames []string
	Builder     func(db database.ConnectionProxy) ([]interface{}, error)
	EventType   string
}

type ServiceTestResult

type ServiceTestResult struct {
	// Message contains helpful text detailing _why_ there was a failure
	Message string
	// Live indicates if the service is available or not
	Live bool
	// Error indicates if there was some fundamental error that prevented a full test
	Error error
}

ServiceTestResult provides a view of a Worker test

func TestServiceWorker

func TestServiceWorker(workerData models.ServiceWorker) ServiceTestResult

TestServiceWorker contacts the indicated worker to verify that it's running

type ServiceWorker

type ServiceWorker interface {
	Build(workerName string, config []byte) error
	Test() ServiceTestResult
	ProcessMetadata(evidenceID int64, payload *NewEvidencePayload) (*models.EvidenceMetadata, error)
	ProcessEvent(payload interface{}) error
}

type TestResp

type TestResp struct {
	Status  string  `json:"status"`
	Message *string `json:"message"`
}

type WebConfigV1

type WebConfigV1 struct {
	BasicServiceWorkerConfig
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
}

Jump to

Keyboard shortcuts

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