Getting started with the service extension
Extend is in Open Beta for AGS Premium Clients! This means that Extend is available for you to try on your development environment. You can submit your feedback here.
Extend is currently available for AGS Starter Closed Beta partners only.
Overview
This document provides a step-by-step guide on how to use Extend Service Extension.
Prerequisites
- Go
- C#
- Java
Windows 10 WSL2 or Linux Ubuntu 20.04 with the following tools installed:
- Make
- Docker v23.x
- docker-compose v2
- Go v1.20
Windows 10 WSL2 or Linux Ubuntu 20.04 with the following tools installed.
- bash
- make
- docker v23.x
- docker-compose v2
- .NET SDK 6
- Go v1.20 (optional, generate grpc-gateway action in Makefile use docker image to compile go)
- [Postman] (optional) (https://www.postman.com/)
- [gRPCurl] (optional) (https://github.com/fullstorydev/grpcurl)
Windows 10 WSL2 or Linux Ubuntu 20.04 with the following tools installed.
- Bash
- Make
- Docker v23.x
- Docker-compose v2
- JDK 17
- Go v1.20 (optional, generate grpc-gateway action in Makefile use docker image to compile go)
- [Postman] (optional) (https://www.postman.com/)
- [gRPCurl] (optional) (https://github.com/fullstorydev/grpcurl)
Access to the AGS demo environment.
- Base URL: https://demo.accelbyte.io.
- Create a game namespace if you don't have one yet.
Keep the
Namespace ID
. - Create an OAuth Client with
confidential
client type. Keep theClient ID
andClient Secret
. This is needed for testing the custom service locally.
The
extend-helper-cli
downloaded, installed, and set up. Download here.
Create an OAuth Client with confidential
client type with the following permission. Keep the Client ID
and Client Secret
.
ADMIN:NAMESPACE:{namespace}:EXTEND:REPOCREDENTIALS
[READ]
If you use extend-helper-cli v0.0.3 or lower, create a user if you don't have any with the following permission. Keep the Username and Password.
ADMIN:NAMESPACE:{namespace}:EXTEND:REPOCREDENTIALS
[READ]
Go to the extend-helper-cli README for more details.
Download the sample app
- Go
- C#
Clone the Service Extension sample app.
git clone https://github.com/AccelByte/extend-service-extension-go
Clone the Service Extension sample app.
git clone https://github.com/AccelByte/extend-service-extension-csharp
Follow the instructions in theREADME.md
file in the sample app repository. The documentation explains how we build the custom service by leveraging gRPC, gRPC-Gateway, and AGS's Cloud Save feature.
This step is mandatory, since you will need to add additional permission to the Client ID you're using:
- ADMIN:ROLE [READ]
- ADMIN:ROLE [READ]
- ADMIN:NAMESPACE:{namespace}:CLOUDSAVE:RECORD [CREATE,READ,UPDATE, DELETE]
Run and test Extend app locally
To have faster iteration on developing the Extend app, you can test it locally. Ensure your client id for local testing already have all the required permission.
- Go
- C#
For more details, please refer to the README.md
especially in the section Running and Testing the Service.
For more details, please refer to the README.md
especially in the section Running and Testing the Service.
Register and integrate custom service to Extend Service Extension
This step will create a Service Extension App that will manage your custom service.
Go to the AGS Admin Portal. Hover over the left sidebar menu option
Extend
and clickService Extension
.Create the app through new app creation page. You can name the app as you prefer. In this guide, we named the app,
guildservice
.You will see the details of your service extension app. Wait until App Repository URL is no longer blank.
Add required permission and build parameter for the custom service
Before we build and deploy the custom service, we need to ensure that the Cloud Save permission needed by the custom service are configured.
Head to the Service Extension
page, where we previously had created our Service Extension app. In this case, we named it guildservice
.
Now, let's note the AB_CLIENT_ID
, and go to the Authorization menu to add the required permission. Use the noted client to search your auth client ID.
After the permission is added, we need to adjust the base path in the custom service.
To change the base path you need to replace the values in 2 places. You get the base value from Service URL
. For example, this Service URL, https://development.accelbyte.io/nngbox-guildservice
, will have the base path /nngbox-guildservice
.
- Go
- C#
in
pkg/common/config.go
, to be accurately this partBasePath = "/guild"
in
pkg/proto/guildService.proto
// OpenAPI options for the entire API.
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
// ...
base_path: "/guild";
// ...
};
For more details, please refer to the Change API base path section in the README.md
file in the custom service repository.
in
gateway/pkg/common/config.go
, to be accurately this partBasePath = "/guild"
in
gateway/pkg/proto/guildService.proto
// OpenAPI options for the entire API.
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
// ...
base_path: "/guild";
// ...
};
For more details, please refer to the Change API base path section in the README.md
file in the custom service repository.
Changing API base path is a mandatory step.
Build and upload the Extend app
After preparing our sample app and configuring all required parameters and permissions, let's build and deploy it.
First of all, we need to configure the extend-helper-cli
stated in the prerequisites, since we will use it
to deploy our sample app.
We only briefly cover how we use the extend-helper-cli
in this guide. To learn more, please refer to the full documentation in GitHub.
$ ./extend-helper-cli-linux_amd64 dockerlogin --namespace nngbox --app guildservice -p | docker login -u AWS --password-stdin 3342674635073.dkr.ecr.us-west-2.amazonaws.com/accelbyte/justice/development/extend/ext-nngbox-ewo48/guildservice
INFO[0000] signing in to https://development.accelbyte.io
INFO[0001] getting docker credentials...
WARNING! Your password will be stored unencrypted in /home/xyz-abc/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
After you've successfully logged in using extend-helper-cli
, let's upload the sample app.
We're using the makefile script in the sample app to upload the sample app.
make imagex_push IMAGE_TAG=v0.0.1 REPO_URL=342674635073.dkr.ecr.us-west-2.amazonaws.com/accelbyte/justice/development/extend/ext-nngbox-ewo48/guildservice
The REPO_URL
can be copied from the app detail page, App Repository URL.
If your images are successfully uploaded, you will see an image with version v0.0.1 in the Image Version History.
Deploy the custom service to Extend Service Extension
To deploy the Extend app, simply click Deploy Latest Image.
Ensure the environment variable PLUGIN_GRPC_SERVER_AUTH_ENABLED
is set to true
, otherwise the endpoint validation (permission.action
and permission.resource
) configured in the guildService.proto
will be ignored
Test the deployed Extend app
To test the app, we can simply go to its apidocs page: <Service URL>/apidocs
. Use the the Service URL shown in details page.
- Go
- C#
For more details, please refer to the Running and Testing the Service section in the README.md
file in the custom service sample app repository.
For more details, please refer to the Running and Testing the Service section in the README.md
file in the custom service repository.
A note on Extend App behavior
In the deployment setup, there's a timeout mechanism for the gRPC Extend app managed by Envoy. This timeout occurs when there's no incoming/outgoing data or request, allowing the system to free up resources. By default, the timeout duration is 300s for streamIdleTimeout
and 30s for routeTimeout
.