serve

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package serve implements the "jig serve" command, serving GRPC services via an evaluator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFS added in v0.0.21

func NewFS(vfs ...fs.FS) fs.FS

NewFS combines the top level directories of multiple fs.FS.

func NewFSFromDirs added in v0.0.21

func NewFSFromDirs(dirs ...string) fs.FS

NewFSFromDirs combines the top level directories of multiple directories.

Types

type Evaluator added in v0.0.21

type Evaluator interface {
	Evaluate(method, input string, vfs fs.FS) (output string, err error)
}

func JsonnetEvaluator added in v0.0.21

func JsonnetEvaluator() Evaluator

type EvaluatorFunc added in v0.0.21

type EvaluatorFunc func(method, input string, vfs fs.FS) (output string, err error)

func (EvaluatorFunc) Evaluate added in v0.0.21

func (ef EvaluatorFunc) Evaluate(method, input string, vfs fs.FS) (output string, err error)

type Option added in v0.0.16

type Option func(s *Server) error

Option is a functional option to configure Server

func WithFileDescriptorSets added in v0.0.32

func WithFileDescriptorSets(fds ...*descriptorpb.FileDescriptorSet) Option

func WithLogger added in v0.0.17

func WithLogger(logger log.Logger) Option

func WithProtosets added in v0.0.19

func WithProtosets(protosets ...string) Option

type Server

type Server struct {
	Files *registry.Files
	// contains filtered or unexported fields
}

func NewServer added in v0.0.14

func NewServer(eval Evaluator, vfs fs.FS, options ...Option) (*Server, error)

NewServer creates a new Server for given evaluator, e.g. Jsonnet and data Directories.

func (*Server) ListenAndServe added in v0.0.14

func (s *Server) ListenAndServe(listenAddr string) error

func (*Server) Serve added in v0.0.14

func (s *Server) Serve(lis net.Listener) error

func (*Server) ServeHTTP added in v0.0.26

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) SetHTTPHandler added in v0.0.28

func (s *Server) SetHTTPHandler(handler http.Handler)

SetHTTPHandler sets a http.Handler to be called for non-grpc traffic. It must be called before Serve or ListenAndServe are called.

func (*Server) Stop added in v0.0.8

func (s *Server) Stop()

func (*Server) UnknownHandler added in v0.0.28

func (s *Server) UnknownHandler(srv interface{}, ss grpc.ServerStream) error

UnknownHandler handles gRPC method calls that are not statically implemented. It is registered as the UnknownServiceHandler of the grpc server.

UnknownHandler can be called from a non-grpc.Server entry point, possibly a HTTP server or even an internal dispatch bypassing the network. In order for this handler to know which method is being invoked, the `srv` argument can be (ab)used to pass the full name of the method. In this case the dynamic type of `srv` must be `protoreflect.FullName` and it must contain the fully-qualified method name (pkg.service.method).

Alternatively, the stream context (ss.Context()) must contain a grpc.ServerTransportStream, retrievable with grpc.ServerTransportStreamFromContext(), on which the `Method()` method will be called to find the method name. This should return the method as a HTTP path (/pkg.service/method), as is done by grpc.Server.

type TestServer added in v0.0.8

type TestServer struct {
	Server
	// contains filtered or unexported fields
}

func NewTestServer added in v0.0.14

func NewTestServer(eval Evaluator, vfs fs.FS, options ...Option) *TestServer

NewTestServer starts and returns a new TestServer. The caller should call Stop when finished, to shut it down.

func NewUnstartedTestServer added in v0.0.32

func NewUnstartedTestServer(eval Evaluator, vfs fs.FS, options ...Option) *TestServer

NewTestServer starts and returns a new TestServer. The caller should call Stop when finished, to shut it down.

func (*TestServer) Addr added in v0.0.8

func (ts *TestServer) Addr() string

func (*TestServer) Start added in v0.0.8

func (ts *TestServer) Start()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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