Skip to content

Instantly share code, notes, and snippets.

View f3nry's full-sized avatar

Paul Henry f3nry

  • Coinbase
  • Oakland, CA
View GitHub Profile
@f3nry
f3nry / output.log
Created February 1, 2019 01:16
gRPC Log Output
http2: Framer 0xc0002c8380: wrote SETTINGS len=0
http2: Framer 0xc0002c8380: read SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=128, INITIAL_WINDOW_SIZE=65536, MAX_FRAME_SIZE=16777215
http2: Framer 0xc0002c8380: read WINDOW_UPDATE len=4 (conn) incr=2147418112
http2: Framer 0xc0002c8380: wrote SETTINGS flags=ACK len=0
http2: Framer 0xc0002c8380: wrote HEADERS flags=END_HEADERS stream=1 len=84
http2: Framer 0xc0002c8380: wrote DATA flags=END_STREAM stream=1 len=12 data="\x00\x00\x00\x00\a\n\x05Hello"
http2: Framer 0xc0002c8380: read SETTINGS flags=ACK len=0
http2: Framer 0xc0002c8380: read HEADERS flags=END_HEADERS stream=1 len=313
http2: Framer 0xc0002c8380: read DATA stream=1 len=15 data="\n\rHello, world."
http2: Framer 0xc0002c8380: read DATA flags=END_STREAM stream=1 len=0 data=""
@f3nry
f3nry / main.go
Created February 1, 2019 01:17
Second Attempt: Responding with protobuf
func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
message := &api.AliveResponse{Message: "Hello, world."}
b, err := proto.Marshal(message)
if err != nil {
return events.APIGatewayProxyResponse{
StatusCode: 500,
}, err
}
@f3nry
f3nry / main.go
Last active February 12, 2019 00:38
Simple Go gRPC Client
package main
import (
"context"
"flag"
"fmt"
"log"
"google.golang.org/grpc"
@f3nry
f3nry / protoc-gen-go.sh
Created February 1, 2019 01:12
Generating proto Go code from a definition
brew install protobuf
go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/protoc-gen-go
protoc -I=./api --go_out=plugins=grpc:./api ./api/hello.proto
@f3nry
f3nry / main.go
Created February 1, 2019 01:17
Third Attempt: Length-prefix Construction
const (
payloadLen = 1
sizeLen = 4
headerLen = payloadLen + sizeLen
)
func msgHeader(data []byte) (hdr []byte, payload []byte) {
hdr = make([]byte, headerLen)
hdr[0] = byte(uint8(0))