Categorygithub.com/bakins/grpc-fastcgi-proxy
modulepackage
0.4.0
Repository: https://github.com/bakins/grpc-fastcgi-proxy.git
Documentation: pkg.go.dev

# README

grpc-fastcgi-proxy

Simple grpc-to-fastcgi proxy.

Status

This is little more than an experiment. It works in the trivial example cases.

Motivation

There is an official grpc client for PHP, but no server support. At my dayjob, we use a lot of PHP, so I wanted to experiment with gRPC servers in PHP.

This project is only the proxy. There is another repo with an example PHP application. That example is used in the testing of this project.

Building/Installing

You need a working Go installation.

Clone this repository into your GOPATH and build the command. For example:

cd $HOME
mkdir -p go/src/github.com/bakins
cd go/src/github.com/bakins
git clone github.com/bakins/grpc-fastcgi-proxy
cd grpc-fastcgi-proxy
go build ./cmd/grpc-fastcgi-proxy

You should now have a grpc-fastcgi-proxy binary

Usage

$ ./grpc-fastcgi-proxy --help
grpc to fastcgi proxy

Usage:
  grpc-fastcgi-proxy [flags]

Flags:
  -a, --address string   listen address (default "127.0.0.1:8080")
  -f, --fastcgi string   fastcgi to proxy (default "127.0.0.1:9000")
  -h, --help             help for grpc-fastcgi-proxy

grpc-fastcgi-proxy is intended to be used with single entrypoint applications. You should do all your routing in index.php, for example. This entry file should be passed as an argument to grpc-fastcgi-proxy:

$ ./grpc-fastcgi-proxy $HOME/git/grpc-fastcgi-example/index.php

It will set the SCRIPT_FILE and DOCUMENT_ROOT cgi variables.

TODO

  • general code cleanup
  • convert HTTP status codes to corresponding gRPC error codes

License

See LICENSE

Acknowledgements

# Packages

No description provided by the author

# Functions

Codec returns a proxying grpc.Codec with the default protobuf codec as parent.
CodecWithParent returns a proxying grpc.Codec with a user provided codec as parent.
NewLogger creates a new logger with our preferred options.
NewServer creates a new Server.
SetAddress creates a function that will set the listening address.
SetAuxAddress creates a function that will set the aux address.
SetEntryFile creates a function that will set the entryfile for php.
SetFastCGIEndpoint creates a function that will set the fastCGI endpoint to proxy.
SetLogger creates a function that will set the logger.

# Structs

Server is an http/2 server that proxies to fastcgi.

# Type aliases

OptionsFunc is a function passed to New to set options.