Skip to main content

Playground

https://github.com/foomo/gotsrpc-playground

The gotsrpc playground is designed to:

  • provide examples for this documentation
  • make it easy to play with gotsrpc on your local machine

It is NOT an example project to build an actual production service, because:

  • it has a purely educational layout
  • all services are exposed from one go program
  • all service implementations are naive demo code with focus on documentation
  • all service implementations are in one package

Installing and running the playground

Prerequisites

  • Go
  • Node.js

Clone repo

git clone git@github.com:foomo/gotsrpc-playground.git ~/go/src/github.com/foomo/gotsrpc-playground

Run playground

cd  ~/go/src/github.com/foomo/gotsrpc-playground
make run

Open the playground http://127.0.0.1:8080

Project layout

Note : this is not a recommendation for a general project layout - it is purely educational.

LocationDescription
serverserver go code
server/servicesservice interfaces, one service interface per package helloworld, todos, ...
server/serverOne package to implement all service interfaces with one file per service package - in a real world scenario, that typically is one package per service interface
server/main.goGo program, that exposes all service implementations and reverse proxies the Next.js frontend which is running on http://127.0.0.1:3000
clientNext.js TypeScript client created with npx create-next-app@latest --typescript
client/services/transport.tsAn example transport implemenation
client/services/generatedTarget for generated TypeScript clients and value objects as defined in gotsrpc.yaml

ie relevant files per example:

FileDescription
server/services/<example>/service.goservice interface definition
server/server/<example>.goservice implementation
client/pages/<example>.tsxNext.js example page
client/styles/<Example>.module.cssCSS