larking

package module
Version: v0.0.0-...-9fd277f Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: BSD-3-Clause Imports: 60 Imported by: 0

README

larking.io

Go Reference

Reflective gRPC transcoding handler. Get started: larking.io/docs

Install

go get larking.io@latest
Install the REPL
go install larking.io/cmd/lark@latest
Install the worker
go install larking.io/cmd/larking@latest

Quickstart

Compile protobuffers to Go:

protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. apipb/*.proto

Create a larking.Mux:

mux, _ := larking.NewMux()

Register services:

mux.RegisterService(&apipb.MyService_ServiceDesc, s) // S is your implementation

Create a server and serve gRPC and REST:

svr, _ := larking.NewServer(mux, larking.InsecureServerOption())
l, _ := net.Listen("tcp", fmt.Sprintf(":%s", *flagPort))
log.Printf("listening on %s", l.Addr().String())
svr.Serve(l)

Debugging

Checkout protobuf at the latest v2 relase. Go install each protoc generation bin.

Regenerate protoc buffers:

protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. testpb/test.proto
Protoc

Must have googleapis protos avaliable. Just link API to /usr/local/include/google so protoc can find it.

ln -s ~/src/github.com/googleapis/googleapis/google/api/ /usr/local/include/google/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPStatusCode

func HTTPStatusCode(c codes.Code) int

func NewOSSignalContext

func NewOSSignalContext(ctx context.Context) (context.Context, func())

NewOSSignalContext tries to gracefully handle OS closure.

func NewStreamContextLogr

func NewStreamContextLogr(log logr.Logger) grpc.StreamServerInterceptor

func NewUnaryContextLogr

func NewUnaryContextLogr(log logr.Logger) grpc.UnaryServerInterceptor

func WSStatusCode

func WSStatusCode(c codes.Code) websocket.StatusCode

Types

type Mux

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

func NewMux

func NewMux(opts ...MuxOption) (*Mux, error)

func (*Mux) Attr

func (m *Mux) Attr(name string) (starlark.Value, error)

func (*Mux) AttrNames

func (v *Mux) AttrNames() []string

func (*Mux) DropConn

func (m *Mux) DropConn(ctx context.Context, cc *grpc.ClientConn) bool

func (*Mux) Freeze

func (m *Mux) Freeze()

func (*Mux) Hash

func (m *Mux) Hash() (uint32, error)

func (*Mux) RegisterConn

func (m *Mux) RegisterConn(ctx context.Context, cc *grpc.ClientConn) error

func (*Mux) RegisterReflectionServer

func (m *Mux) RegisterReflectionServer(s *grpc.Server)

RegisterReflectionServer registers the server reflection service for multiple proxied gRPC servers. Each individual reflection stream is merged to provide a consistent view at the point of stream creation.

func (*Mux) RegisterService

func (m *Mux) RegisterService(sd *grpc.ServiceDesc, ss interface{})

RegisterService satisfies grpc.ServiceRegistrar for generated service code hooks.

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Mux) StreamHandler

func (m *Mux) StreamHandler() grpc.StreamHandler

StreamHandler returns a gRPC stream handler to proxy gRPC requests.

func (*Mux) String

func (m *Mux) String() string

func (*Mux) Truth

func (m *Mux) Truth() starlark.Bool

func (*Mux) Type

func (m *Mux) Type() string

type MuxOption

type MuxOption func(*muxOptions)

func StatsOption

func StatsOption(h stats.Handler) MuxOption

func StreamServerInterceptorOption

func StreamServerInterceptorOption(interceptor grpc.StreamServerInterceptor) MuxOption

func UnaryServerInterceptorOption

func UnaryServerInterceptorOption(interceptor grpc.UnaryServerInterceptor) MuxOption

type Server

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

func NewServer

func NewServer(mux *Mux, opts ...ServerOption) (*Server, error)

NewServer creates a new Proxy server.

func (*Server) Close

func (s *Server) Close() error

func (*Server) Serve

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

Serve accepts incoming connections on the listener. Serve will return always return a non-nil error, http.ErrServerClosed.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

type ServerOption

type ServerOption func(*serverOptions) error

ServerOption is similar to grpc.ServerOption.

func HTTPHandlerOption

func HTTPHandlerOption(pattern string, handler http.Handler) ServerOption

func InsecureServerOption

func InsecureServerOption() ServerOption

func LogOption

func LogOption(log logr.Logger) ServerOption

func MuxHandleOption

func MuxHandleOption(patterns ...string) ServerOption

func TLSCredsOption

func TLSCredsOption(c *tls.Config) ServerOption

type StarlarkService

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

func (*StarlarkService) Attr

func (s *StarlarkService) Attr(name string) (starlark.Value, error)

HasAttrs with each one being callable.

func (*StarlarkService) AttrNames

func (s *StarlarkService) AttrNames() []string

func (*StarlarkService) Freeze

func (s *StarlarkService) Freeze()

func (*StarlarkService) Hash

func (s *StarlarkService) Hash() (uint32, error)

func (*StarlarkService) String

func (s *StarlarkService) String() string

func (*StarlarkService) Truth

func (s *StarlarkService) Truth() starlark.Bool

func (*StarlarkService) Type

func (s *StarlarkService) Type() string

type StarlarkStream

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

func (*StarlarkStream) Attr

func (s *StarlarkStream) Attr(name string) (starlark.Value, error)

func (*StarlarkStream) AttrNames

func (v *StarlarkStream) AttrNames() []string

func (*StarlarkStream) Close

func (s *StarlarkStream) Close() error

func (*StarlarkStream) Freeze

func (s *StarlarkStream) Freeze()

func (*StarlarkStream) Hash

func (s *StarlarkStream) Hash() (uint32, error)

func (*StarlarkStream) Name

func (s *StarlarkStream) Name() string

func (*StarlarkStream) String

func (s *StarlarkStream) String() string

func (*StarlarkStream) Truth

func (s *StarlarkStream) Truth() starlark.Bool

func (*StarlarkStream) Type

func (s *StarlarkStream) Type() string

type StarlarkUnary

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

func (*StarlarkUnary) CallInternal

func (s *StarlarkUnary) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

func (*StarlarkUnary) Freeze

func (s *StarlarkUnary) Freeze()

func (*StarlarkUnary) Hash

func (s *StarlarkUnary) Hash() (uint32, error)

func (*StarlarkUnary) Name

func (s *StarlarkUnary) Name() string

func (*StarlarkUnary) String

func (s *StarlarkUnary) String() string

func (*StarlarkUnary) Truth

func (s *StarlarkUnary) Truth() starlark.Bool

func (*StarlarkUnary) Type

func (s *StarlarkUnary) Type() string

Directories

Path Synopsis
apipb
cmd
lark
lark
lark
laze
Implements a laze scheduler.
Implements a laze scheduler.
examples
Package health provides a service that exposes server's health and it must be imported to enable support for client-side health checks.
Package health provides a service that exposes server's health and it must be imported to enable support for client-side health checks.
archive/starlarktar
https://pkg.go.dev/archive/tar
https://pkg.go.dev/archive/tar
archive/starlarkzip
https://pkg.go.dev/archive/zip
https://pkg.go.dev/archive/zip
encoding/starlarkproto
Package starlarkproto provides support for protocol buffers.
Package starlarkproto provides support for protocol buffers.
net/starlarkhttp
Package http provides HTTP client implementations.
Package http provides HTTP client implementations.
starlarkblob
Package blob provides access to blob objects within a storage location.
Package blob provides access to blob objects within a storage location.
starlarkdocstore
Package starlarkdocstore supports noSQL document databases.
Package starlarkdocstore supports noSQL document databases.
starlarkerrors
Package errors implements functions to manipulate errors.
Package errors implements functions to manipulate errors.
starlarkio
Package starlarkio implements readers and writers.
Package starlarkio implements readers and writers.
starlarkpubsub
Package starlarkpubsub provides methods for publishing and recieving messages.
Package starlarkpubsub provides methods for publishing and recieving messages.
starlarkrule
Laze is a task scheduler inspired by Bazel and the Go build tool.
Laze is a task scheduler inspired by Bazel and the Go build tool.
starlarkruntimevar
Package runtimevar adds configuration variables at runtime.
Package runtimevar adds configuration variables at runtime.
starlarksql
Package sql provides an interface to conntect to SQL databases.
Package sql provides an interface to conntect to SQL databases.
starlarkstruct
Package starlarkstruct defines the Starlark types 'struct' and 'module', both optional language extensions.
Package starlarkstruct defines the Starlark types 'struct' and 'module', both optional language extensions.

Jump to

Keyboard shortcuts

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