middle

package
v0.0.0-...-3185076 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(configPath string)

func Setup

func Setup() *cobra.Command

func SetupHTTPServer

func SetupHTTPServer(responder Responder)

Types

type Client

type Client struct {
	HttpClient http.Client
	ServerURL  string
	Tracer     trace.Tracer
}

func NewClient

func NewClient(serverHost string, serverPort int) *Client

func (*Client) SubmitJob

func (c *Client) SubmitJob(methodContext context.Context, job *JobRequest) (*JobResult, error)

type Config

type Config struct {
	Port           int
	JaegerURL      string
	BottomHost     string
	BottomPort     int
	BottomGRPCPort int
}

type JobRequest

type JobRequest struct {
	JobId    string
	Function string
	Args     []int
}

type JobResult

type JobResult struct {
	Request *JobRequest
	Answer  int
}

type Middle

type Middle struct {
	//Actions      chan func()
	//Jobs         map[JobState][]*JobStatus
	//Tracer       trace.Tracer
	BottomClient     *bottom.Client
	BottomGRPCClient *bottom.GRPCClient
}

func NewMiddle

func NewMiddle(stop <-chan struct{}, workerHost string, workerPort int, grpcPort int) *Middle

func (*Middle) Error

func (q *Middle) Error(w http.ResponseWriter, r *http.Request, err error, statusCode int)

func (*Middle) NotFound

func (q *Middle) NotFound(w http.ResponseWriter, r *http.Request)

func (*Middle) SubmitJob

func (q *Middle) SubmitJob(ctx context.Context, job *JobRequest) (*JobResult, error)

func (*Middle) SubmitJobGRPC

func (q *Middle) SubmitJobGRPC(ctx context.Context, job *JobRequest) (*JobResult, error)

func (*Middle) SubmitJobHttp

func (q *Middle) SubmitJobHttp(ctx context.Context, job *JobRequest) (*JobResult, error)

type Responder

type Responder interface {
	SubmitJob(ctx context.Context, job *JobRequest) (*JobResult, error)

	NotFound(w http.ResponseWriter, r *http.Request)
	Error(w http.ResponseWriter, r *http.Request, err error, statusCode int)
}

Jump to

Keyboard shortcuts

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