GithubHelp home page GithubHelp logo

example-advanced-sample-app-grpc-golang's Introduction

example-advanced-sample-app-grpc-golang

flowchart LR
   subgraph AB Cloud Service
   CL[gRPC Client]
   end
   subgraph gRPC Server Deployment
   SV["gRPC Server\n(YOU ARE HERE)"]
   DS[Dependency Services]
   CL --- DS
   end
   DS --- SV
Loading

AccelByte Gaming Services capabilities can be extended using custom functions implemented in a gRPC server. If configured, custom functions in the gRPC server will be called by AccelByte Gaming Services instead of the default function.

The gRPC server and the gRPC client can actually communicate directly. However, additional services are necessary to provide security, reliability, scalability, and observability. We call these services as dependency services. The grpc-plugin-dependencies repository is provided as an example of what these dependency services may look like. It contains a docker compose which consists of these dependency services.

⚠️ grpc-plugin-dependencies is provided as example for local development purpose only: The dependency services in the actual gRPC server deployment may not be exactly the same.

Overview

This repository contains sample matchmaking function gRPC server app written in Go, It provides simple custom matchmaking function implementation for matchmaking service in AccelByte Gaming Services.

This sample app also shows how this gRPC server can be instrumented for better observability. It is configured by default to send metrics, traces, and logs to the observability dependency services in grpc-plugin-dependencies.

Prerequisites

  1. Windows 10 WSL2 or Linux Ubuntu 20.04 with the following tools installed.

    a. bash

    b. make

    c. docker v23.x

    d. docker-compose v2.x

    e. docker loki driver

    docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
    

    f. go 1.18

  2. Access to AccelByte Gaming Services demo environment.

    a. Base URL: https://demo.accelbyte.io

    b. Create a Game Namespace if you don't have one yet. Keep the Namespace ID.

    c. Create an OAuth Client with confidential client type with the following permission. Keep the Client ID and Client Secret.

    • NAMESPACE:{namespace}:MMV2GRPCSERVICE [READ]

Setup

To be able to run this sample app, you will need to follow these setup steps.

  1. Create a docker compose .env file by copying the content of .env.template file.

    ⚠️ The host OS environment variables have higher precedence compared to .env file variables: If the variables in .env file do not seem to take effect properly, check if there are host OS environment variables with the same name. See documentation about docker compose environment variables precedence for more details.

  2. Fill in the required environment variables in .env file as shown below.

    AB_BASE_URL=https://demo.accelbyte.io      # Base URL of AccelByte Gaming Services demo environment
    AB_CLIENT_ID='xxxxxxxxxx'         # Client ID from the Prerequisites section
    AB_CLIENT_SECRET='xxxxxxxxxx'     # Client Secret from the Prerequisites section
    AB_NAMESPACE='xxxxxxxxxx'                  # Namespace ID from the Prerequisites section
    PLUGIN_GRPC_SERVER_AUTH_ENABLED=false      # Enable or disable access token and permission verification
    

    ⚠️ Keep PLUGIN_GRPC_SERVER_AUTH_ENABLED=false for now: It is currently not supported by AccelByte Gaming Services, but it will be enabled later on to improve security. If it is enabled, the gRPC server will reject any calls from gRPC clients without proper authorization metadata.

Building

To build this sample app, use the following command.

make build

Running

To (build and) run this sample app in a container, use the following command.

docker-compose up --build

Pushing

To build and push this sample app multi-arch container image to AWS ECR, use the following command.

make imagex_push REPO_URL=xxxxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/accelbyte/justice/development/extend/xxxxxxxxxx/xxxxxxxxxx IMAGE_TAG=v0.0.1

example-advanced-sample-app-grpc-golang's People

Contributors

zthacker avatar dhanarab avatar abdularis avatar elmernocon avatar

Watchers

Anggoro Dewanto avatar  avatar Hendra Darwintha avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.