server

package
v0.0.0-...-69999d2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 25 Imported by: 2

Documentation

Overview

Package server contains code for serving the Funnel API, and accessing database backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMarshaler

func NewMarshaler() runtime.Marshaler

Types

type CustomMarshal

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

CustomMarshal is a custom marshaler for the GRPC gateway that returns the required fields based on the View value: - View_MINIMAL: returns only the id and state fields - View_BASIC: returns the id, state, creation_time, description, name, inputs, outputs, resources, tags, volumes, executors, and logs fields - View_FULL: returns all fields

This could be improved by updating the generated protobuf code to include the View field in the Task struct Related discussion: https://github.com/ohsu-comp-bio/funnel/pull/716#discussion_r1375155983

func (*CustomMarshal) ContentType

func (marshal *CustomMarshal) ContentType(i interface{}) string

ContentType return content type of marshler

func (*CustomMarshal) DetectView

func (mclean *CustomMarshal) DetectView(task *tes.Task) (tes.View, error)

func (*CustomMarshal) Marshal

func (mclean *CustomMarshal) Marshal(v interface{}) ([]byte, error)

Marshal serializes v into a JSON encoded byte array. If v is of type `proto.Message` the then field "result" is extracted and returned by itself. This is mainly to get around a weird behavior of the GRPC gateway streaming output

func (*CustomMarshal) MarshalList

func (mclean *CustomMarshal) MarshalList(list *tes.ListTasksResponse) ([]byte, error)

func (*CustomMarshal) MarshalTask

func (mclean *CustomMarshal) MarshalTask(task *tes.Task) ([]byte, error)

func (*CustomMarshal) NewDecoder

func (mclean *CustomMarshal) NewDecoder(r io.Reader) runtime.Decoder

NewDecoder shims runtime.Marshaler.NewDecoder

func (*CustomMarshal) NewEncoder

func (mclean *CustomMarshal) NewEncoder(w io.Writer) runtime.Encoder

NewEncoder shims runtime.Marshaler.NewEncoder

func (*CustomMarshal) TranslateTask

func (mclean *CustomMarshal) TranslateTask(task *tes.Task, view tes.View) interface{}

func (*CustomMarshal) Unmarshal

func (mclean *CustomMarshal) Unmarshal(data []byte, v interface{}) error

Unmarshal shims runtime.Marshaler.Unmarshal

type JSONError

type JSONError struct {
	Error string `json:"error"`
}

type Server

type Server struct {
	RPCAddress       string
	HTTPPort         string
	BasicAuth        []config.BasicCredential
	Tasks            tes.TaskServiceServer
	Events           events.EventServiceServer
	Nodes            scheduler.SchedulerServiceServer
	DisableHTTPCache bool
	Log              *logger.Logger
}

Server represents a Funnel server. The server handles RPC traffic via gRPC, HTTP traffic for the TES API, and also serves the web dashboard.

func (*Server) Serve

func (s *Server) Serve(pctx context.Context) error

Serve starts the server and does not block. This will open TCP ports for both RPC and HTTP.

type TaskService

type TaskService struct {
	tes.UnimplementedTaskServiceServer
	Name    string
	Event   events.Writer
	Compute events.Computer
	Read    tes.ReadOnlyServer
	Log     *logger.Logger
}

TaskService is a wrapper which handles common TES Task Service operations, such as initializing a task when CreateTask is called. The TaskService is backed by two parts: a read API which provides the GetTask and ListTasks endpoints, and a write API which implements the events.Writer interface. Task creation and cancelation is managed by writing events to underlying event writer.

This makes it easier to define task service backends for new databases, and ensures that common operations are handled consistently, such as setting IDs, handling 404s, GetServiceInfo, etc.

func (*TaskService) CancelTask

CancelTask cancels a task

func (*TaskService) CreateTask

func (ts *TaskService) CreateTask(ctx context.Context, task *tes.Task) (*tes.CreateTaskResponse, error)

CreateTask provides an HTTP/gRPC endpoint for creating a task. This is part of the TES implementation.

func (*TaskService) GetServiceInfo

func (ts *TaskService) GetServiceInfo(ctx context.Context, info *tes.GetServiceInfoRequest) (*tes.ServiceInfo, error)

GetServiceInfo returns service metadata.

func (*TaskService) GetTask

func (ts *TaskService) GetTask(ctx context.Context, req *tes.GetTaskRequest) (*tes.Task, error)

GetTask calls GetTask on the underlying tes.ReadOnlyServer. If the underlying server returns tes.ErrNotFound, TaskService will handle returning the appropriate gRPC error.

func (*TaskService) ListTasks

ListTasks calls ListTasks on the underlying tes.ReadOnlyServer.

Jump to

Keyboard shortcuts

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