• Stars
    star
    285
  • Rank 142,057 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An example repo of how I like to use postgres with gRPC

grpc-postgres

An example repo of how I like to use postgres with gRPC

  +------------------------+
  |   ____  ______  ___    |
  |  /    )/      \/   \   |
  | (     / __    _\    )  |
  |  \    (/ o)  ( o)   )  |
  |   \_  (_  )   \ )  /   |
  |     \  /\_/    \)_/    |
  |      \/  //|  |\\      |
  |          v |  | v      |
  |            \__/        |
  |                        |
  +------------------------+

Source: Charles Clavadetscher

Usage

First, start a postgres container:

$ docker run --rm -d --name postgres -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=mypass -e POSTGRES_DB=postgres postgres:13
d1a2eb0fb44da9c3488184f5296da28d1c7f88bd32bd4ec81fc254f006886b03

Start the server:

$ POSTGRES_URL=postgresql://postgres:mypass@localhost:5432/postgres?sslmode=disable go run main.go
...
{"level":"info","msg":"Serving gRPC on [::]:8080"}
{"level":"info","msg":"Serving Web UI on http://0.0.0.0:8080"}

Navigate to http://0.0.0.0:8080 to see the auto-generated web UI for the service, courtesy of gRPC reflection and github.com/fullstorydev/grpcui!

gRPCUI

Usage with Cockroach DB

The application also supports talking to a Cockroach DB instance, by using the cockroachdb scheme:

cockroachdb://user:password@host:5432/defaultdb

The scheme is used when performing the database migrations, as the behaviour changes based on the database.

Developing

Requirements

  • go > 1.16

Making changes

After making any changes to the proto file or the migrations, make sure to regenerate the files:

$ make generate

If you want to change the schema of the database, add another migration file. Use the same naming format, with the new file names starting 2_. Make sure to run make generate and increment the migration version in users/helpers.go.

More Repositories

1

grpc-gateway-boilerplate

All the boilerplate you need to get started with writing grpc-gateway powered REST services in Go
Go
464
star
2

certify

Automatic client and server certificate distribution and maintenance
Go
462
star
3

grpc-auth-example

Examples of client authentication with gRPC
Go
97
star
4

grpcweb-example

An example implementation of a GopherJS client and a Go server using the Improbable gRPC-Web implementation
Go
94
star
5

protobuf

GopherJS Bindings for ProtobufJS and gRPC-Web
Go
81
star
6

wasm-experiments

Go
63
star
7

grpc-web-compatibility-test

Test various implementations of gRPC-Web Clients with various implementations of gRPC-Web proxies
JavaScript
62
star
8

grpc-wasm

gRPC-Web implementation in Go, built using the WASM architecture target
Go
50
star
9

grpc-json-example

Example of using gRPC-Go with JSON as the transport encoding
Go
49
star
10

grpcweb-wasm-example

Small example server using gRPC-Web via the gRPC-Go WASM fork
JavaScript
47
star
11

grpcweb-boilerplate

A minimal repo containing all the boilerplate for getting started with GopherJS using gRPC-Web
Go
44
star
12

chunker

Small demo of a server splitting binary blobs into streamed chunks
Go
39
star
13

connect-gateway-example

Example of using the gRPC-Gateway with Connect
Go
26
star
14

gopherjs-grpc-websocket

An example implementation of bridging gRPC with a GopherJS frontend over Websockets
Go
25
star
15

grpc-web-go-react-example

Example of using Go and React/TypeScript with gRPC-Web
TypeScript
24
star
16

rust-grpc-web-wasm-test

Go
15
star
17

sortslice

Warn if user provides a non-slice to sort.Slice
Go
12
star
18

bazel-mono

Playing around with using Bazel for CI
Starlark
11
star
19

gogoproto-experiments

Testing various Go protobuf and gRPC packages with GoGoProtobuf
Go
9
star
20

redeploy

Simple application for redeploying containers when Docker hub webhooks are sent
Go
8
star
21

protoc-gen-gopherjs

This repo has moved
8
star
22

presentations

My presentations
Go
7
star
23

go-protobuf-plugin-versioning-example

An example of easy consistent versioning of Go based Protobuf plugins
Go
6
star
24

simple-grpc

Minimal gRPC example
Go
6
star
25

collapse-gitlab-files

A small userscript for collapsing all files on a GitLab merge request diffs page
JavaScript
5
star
26

concurrency

Concurrency example
Go
5
star
27

grpc-web-generators

Dockerfile for generating grpc-web protofiles.
Dockerfile
5
star
28

fetch

The Go http.Transport interface implemented over the WHATWG Fetch API
Go
5
star
29

gopherjs-grpc-web-example

Example implementation of a GopherJS gRPC-web client talking to a Go gRPC server
Go
4
star
30

blog

My blog
HTML
4
star
31

gopherjs-json

Convenience functions for interacting with JSON in GopherJS
Go
3
star
32

papers

Collection of talk proposals
3
star
33

cat-collection

JavaScript
3
star
34

hashipet

HashiPet API
Go
3
star
35

bomberman

A bomberman clone me and some friends from uni made as part of a C++ project
C++
2
star
36

chronic-pain-tracker

Tracks pain through the day
Go
2
star
37

rust-experiments

2
star
38

delete-gitlab-registry-tags

Simple userscript that adds a button to the GitLab registry page for mass tag deletion
JavaScript
2
star
39

aoc2019

Advent of Code 2019
Rust
2
star
40

grpcweb-presentation

Files for my presentation about my gRPC-Web bindings
Protocol Buffer
2
star
41

gopherjs-grpc-web

A GopherJS binding and generator for gRPC-web
JavaScript
2
star
42

rag-experiment

Go
2
star
43

templ-exp

1
star
44

websocket

Implementing Go interfaces in WASM using the Websockets API
1
star
45

buf-example

Using buf to develop APIs with protocol buffers
1
star
46

docker-go-protobuf

For building a simple Docker container with Go and Protobuf installed
1
star
47

moq-vendor-bug

Go
1
star
48

go-wazero-experimenting

Go
1
star
49

grpc-web

gRPC-Web implementation in Rust, targeting WebAssembly
1
star