backend

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: BSD-3-Clause Imports: 39 Imported by: 0

Documentation

Overview

Package backend is goma service backend of /cxx-compiler-service/*.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	// Auth checks HTTP access, and returns new context with enduser info.
	Auth(context.Context, *http.Request) (context.Context, error)
}

Auth authenticates the request.

type Backend

type Backend interface {
	Ping() http.Handler
	Exec() http.Handler
	ByteStream() http.Handler
	StoreFile() http.Handler
	LookupFile() http.Handler
	Execlog() http.Handler
}

Backend is interface of backend for frontend. TODO: provides switching backend, httprpc backend (e.g. to clients5.google.com/cxx-compiler-service/*) and remote backend (e.g. to <cluster>.endpoints.<project>.cloud.goog)

func FromProto

func FromProto(ctx context.Context, cfg *pb.BackendConfig, opt Option) (Backend, func(), error)

FromProto creates Backend based on cfg. returned func will release resources associated with Backend.

type ExecServer

type ExecServer struct {
	Client execpb.ExecServiceClient
}

ExecServer handles /e.

func (ExecServer) Exec

func (s ExecServer) Exec(ctx context.Context, req *gomapb.ExecReq) (*gomapb.ExecResp, error)

Exec handles /e.

type ExeclogServer

type ExeclogServer struct {
	Client execlogpb.LogServiceClient
}

ExeclogServer handles /sl.

func (ExeclogServer) SaveLog

SaveLog handles /sl.

type FileServer

type FileServer struct {
	Client filepb.FileServiceClient
}

FileServer handles /s and /l.

func (FileServer) LookupFile

LookupFile handles /l.

func (FileServer) StoreFile

StoreFile handles /s.

type GRPC

type GRPC struct {
	ExecServer
	FileServer
	ExeclogServer

	ByteStreamClient bspb.ByteStreamClient

	Auth Auth
	// api key. used for remote backend.
	APIKey string

	// trace prefix and label. used for local backend.
	Namespace string
	Cluster   string
}

GRPC is grpc backend in the same cluster (local) or other cluter (remote).

func FromLocalBackend

func FromLocalBackend(ctx context.Context, cfg *pb.LocalBackend, opt Option) (GRPC, func(), error)

FromLocalBackend creates new GRPC from cfg. returned func would release resources associated with GRPC.

func FromRemoteBackend

func FromRemoteBackend(ctx context.Context, cfg *pb.RemoteBackend, opt Option) (GRPC, func(), error)

FromRemoteBackend creates new GRPC from cfg. returned func would release resources associated with GRPC.

func (GRPC) ByteStream

func (g GRPC) ByteStream() http.Handler

ByteStream returns http handler for bytestream.

func (GRPC) Exec

func (g GRPC) Exec() http.Handler

Exec returns http handler for exec request.

func (GRPC) Execlog

func (g GRPC) Execlog() http.Handler

Execlog returns http handler for execlog request.

func (GRPC) LookupFile

func (g GRPC) LookupFile() http.Handler

LookupFile returns http handler for lookup file request.

func (GRPC) Ping

func (g GRPC) Ping() http.Handler

Ping returns http handler for ping.

func (GRPC) StoreFile

func (g GRPC) StoreFile() http.Handler

StoreFile returns http handler for store file request.

type HTTPRPC

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

HTTPRPC is httprpc backend.

func FromHTTPRPCBackend

func FromHTTPRPCBackend(ctx context.Context, cfg *pb.HttpRpcBackend) (HTTPRPC, func(), error)

FromHTTPRPCBackend creates new httprpc backend from cfg.

func NewHTTPRPC

func NewHTTPRPC(target *url.URL) HTTPRPC

NewHTTPRPC creates httprpc backend proxies to target (scheme + host). target's path etc will be ignored.

func (HTTPRPC) ByteStream

func (h HTTPRPC) ByteStream() http.Handler

ByteStream forwards requests to target.

func (HTTPRPC) Exec

func (h HTTPRPC) Exec() http.Handler

Exec forwards requests to target.

func (HTTPRPC) Execlog

func (h HTTPRPC) Execlog() http.Handler

Execlog forwards requests to target.

func (HTTPRPC) LookupFile

func (h HTTPRPC) LookupFile() http.Handler

LookupFile forwards requests to target.

func (HTTPRPC) Ping

func (h HTTPRPC) Ping() http.Handler

Ping forwards requests to target.

func (HTTPRPC) StoreFile

func (h HTTPRPC) StoreFile() http.Handler

StoreFile forwards requests to target.

type Mixer

type Mixer struct {
	Auth Auth
	// contains filtered or unexported fields
}

Mixer is mixer backend, dispatched by group of enduser.

func FromBackendRule

func FromBackendRule(ctx context.Context, cfg *pb.BackendRule, opt Option) (mixer Mixer, cleanup func(), err error)

FromBackendRule creates new Mixer from cfg. returned func would release resources associated with Mixer.

func (Mixer) ByteStream

func (m Mixer) ByteStream() http.Handler

func (Mixer) Exec

func (m Mixer) Exec() http.Handler

func (Mixer) Execlog

func (m Mixer) Execlog() http.Handler

func (Mixer) LookupFile

func (m Mixer) LookupFile() http.Handler

func (Mixer) Ping

func (m Mixer) Ping() http.Handler

func (Mixer) StoreFile

func (m Mixer) StoreFile() http.Handler

type Option

type Option struct {
	Auth      Auth
	APIKeyDir string
}

Option is backend option.

Jump to

Keyboard shortcuts

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