Need help with grpc-postgres?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

johanbrandhorst
150 Stars 24 Forks MIT License 45 Commits 0 Opened issues

Description

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

Services available

!
?

Need anything else?

Contributors list

# 6,047
Go
gRPC
adafrui...
golang
40 commits
# 278,000
Shell
openlay...
vector-...
golang
1 commit

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:

$ go run main.go --postgres-url postgresql://postgres:[email protected]:5432/postgres
...
INFO[May 21 22:51:37.091] Serving gRPC on [::]:10000
INFO[May 21 22:51:37.156] Serving Web UI on https://localhost:10000

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

gRPCUI

Developing

Requirements

  • go
    > 1.14

Run

make install
to install the generation dependencies:
$ make install

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
.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.