grpc

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2018 License: MIT Imports: 23 Imported by: 1

README

PHP-GRPC

Latest Stable Version GoDoc Build Status Go Report Card Codecov

PHP-GRPC is an open source (MIT licensed) high-performance PHP GRPC server build at top of RoadRunner. Server support both PHP and Golang services running within one application.

Features:

  • comliant with native Golang GRPC services
  • very fast, minimal proxy overlay
  • easy TLS configuration
  • debug tools included
  • middleware and server options support
  • code generation using protoc plugin
  • transport, message, worker error management
  • response error codes over php exceptions
  • works on Windows

License:

The MIT License (MIT). Please see LICENSE for more information. Maintained by SpiralScout.

Documentation

Index

Constants

View Source
const ID = "grpc"

ID sets public GRPC service ID for roadrunner.Container.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Address to listen.
	Listen string

	// Proto file associated with the service.
	Proto string

	// TLS defined authentication method (TLS for now).
	TLS TLS

	// Workers configures roadrunner grpc and worker pool.
	Workers *roadrunner.ServerConfig
}

Config describes GRPC service configuration.

func (*Config) EnableTLS

func (c *Config) EnableTLS() bool

EnableTLS returns true if rr must listen TLS connections.

func (*Config) Hydrate

func (c *Config) Hydrate(cfg service.Config) error

Hydrate the config and validate it's values.

func (*Config) Listener

func (c *Config) Listener() (net.Listener, error)

Listener creates new rpc socket Listener.

func (*Config) Valid

func (c *Config) Valid() error

Valid validates the configuration.

type Proxy

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

Proxy manages GRPC/RoadRunner bridge.

func NewProxy

func NewProxy(name string, metadata string, rr *roadrunner.Server) *Proxy

NewProxy creates new service proxy object.

func (*Proxy) RegisterMethod

func (p *Proxy) RegisterMethod(method string)

RegisterMethod registers new RPC method.

func (*Proxy) ServiceDesc

func (p *Proxy) ServiceDesc() *grpc.ServiceDesc

ServiceDesc returns service description for the proxy.

type Service

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

Service manages set of GPRC registerServices, options and connections.

func (*Service) AddListener

func (s *Service) AddListener(l func(event int, ctx interface{}))

AddListener attaches grpc event watcher.

func (*Service) AddOption

func (s *Service) AddOption(opt grpc.ServerOption)

AddOption adds new GRPC server option. Codec and TLS options are controlled by service internally.

func (*Service) AddService

func (s *Service) AddService(r func(server *grpc.Server)) error

AddService would be invoked after GRPC service creation.

func (*Service) Init

func (s *Service) Init(cfg *Config, r *rpc.Service, e env.Environment) (ok bool, err error)

Init service.

func (*Service) Serve

func (s *Service) Serve() (err error)

Serve GRPC grpc.

func (*Service) Stop

func (s *Service) Stop()

Stop the service.

type TLS

type TLS struct {
	// Key defined private server key.
	Key string

	// Cert is https certificate.
	Cert string
}

TLS defines auth credentials.

type WorkerList

type WorkerList struct {
	// Workers is list of workers.
	Workers []*util.State `json:"workers"`
}

WorkerList contains list of workers.

Directories

Path Synopsis
cmd
rr-grpc command
example
client command
Package service is a generated protocol buffer package.
Package service is a generated protocol buffer package.
ext
Package tests is a generated protocol buffer package.
Package tests is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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