Using Amazon Event Bridge
Using Amazon Event Bridge Extending GS2 functionality with Amazon Event Bridge.
GS2 provides several functions as microservices. However, there may be situations where you want to extend the functionality.
GS2-Script provides scripting capabilities using the Lua language and can extend the functionality of GS2 microservices. Scripts written in GS2-Script are not invoked at all times, but are executed in response to triggers defined by each GS2 microservice.
For example, GS2-Account has the following triggers
For each of these, “synchronous processing” and “asynchronous processing” are available as the timing for script execution.
Type | Description | |
---|---|---|
namespace | Namespace | Namespace |
account | Account | Game player’s account |
Type | Required | Default | Value Constraints | Description | |
---|---|---|---|---|---|
permit | bool | ✓ | Whether to allow creating an account |
namespace = args.namespace
account = args.account
result = {
permit=permit
}
When synchronous processing is set for a trigger, API processing is blocked until script execution is complete. Instead of slowing down the response time of the API for the duration of the script execution, you can “fake” the results of the script or “stop processing”.
To give a more concrete example, you can use a script to double the amount of experience gained from a quest, or to cause a response error if the party formed at the start of a quest does not include a certain character.
When asynchronous processing is set for a trigger, the script is executed asynchronously after the API responds.
If you want to implement a ranking based on the number of items owned, you can assign an asynchronous script to the trigger when an item is acquired or consumed. This allows you to register the number of items owned as a score in the ranking without affecting the response time of the API.
GS2 can use the Amazon Event Bridge provided by AWS to implement asynchronous processing. See the separate document for details on using the Amazon Event Bridge.
Using Amazon Event Bridge Extending GS2 functionality with Amazon Event Bridge.