GS2-Distributor Deploy/CDK Reference
Entities
Resources targeted by the Deploy operation
Namespace
Namespace
A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts. Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the namespace differs, the data is treated as a completely independent data space.
Therefore, you must create a namespace before you can start using each service.
Request
Resource creation and update requests
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| transactionSetting | TransactionSetting | Transaction Settings Configuration for controlling how distributed transactions are executed when processing resource distribution. Supports auto-run, atomic commit, and async processing options. | ||||
| assumeUserId | string | ~ 1024 chars | GS2-Identifier User GRN | |||
| autoRunStampSheetNotification | NotificationSetting | ✓ | Push notification when transaction auto-execution is complete(Old specification) Configuration for sending push notifications via GS2-Gateway when a transaction completes auto-execution on the server side. This is the legacy specification; use autoRunTransactionNotification for the new specification. | |||
| autoRunTransactionNotification | NotificationSetting | ✓ | Push notification when transaction auto-execution is complete Configuration for sending push notifications via GS2-Gateway when a distributed transaction completes auto-execution on the server side. Notifies the client of the transaction result so it can update the local state accordingly. | |||
| logSetting | LogSetting | Log Output Settings Configuration for outputting log data of distributor operations to GS2-Log. By specifying a GS2-Log namespace, API request and response logs for resource distribution, transaction execution, and transaction processing can be collected. |
GetAttr
Resource creation results that can be retrieved using the !GetAttr tag
| Type | Description | |
|---|---|---|
| Item | Namespace | Namespace created |
Implementation Example
Type: GS2::Distributor::Namespace
Properties:
Name: namespace-0001
Description: null
TransactionSetting: null
AssumeUserId: grn:gs2::YourOwnerId:identifier:user:user-0001
AutoRunStampSheetNotification: null
AutoRunTransactionNotification: null
LogSetting:
LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001import (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/distributor"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
distributor.NewNamespace(
&SampleStack,
"namespace-0001",
distributor.NamespaceOptions{
AssumeUserId: pointy.String("grn:gs2::YourOwnerId:identifier:user:user-0001"),
LogSetting: &core.LogSetting{
LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
new \Gs2Cdk\Distributor\Model\Namespace_(
stack: $this,
name: "namespace-0001",
options: new \Gs2Cdk\Distributor\Model\Options\NamespaceOptions(
assumeUserId: "grn:gs2::YourOwnerId:identifier:user:user-0001",
logSetting: new \Gs2Cdk\Core\Model\LogSetting(
loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
)
);
}
}
print((new SampleStack())->yaml()); // Generate Templateclass SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.distributor.model.Namespace(
this,
"namespace-0001",
new io.gs2.cdk.distributor.model.options.NamespaceOptions()
.withAssumeUserId("grn:gs2::YourOwnerId:identifier:user:user-0001")
.withLogSetting(new io.gs2.cdk.core.model.LogSetting(
"grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
))
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Distributor.Model.Namespace(
stack: this,
name: "namespace-0001",
options: new Gs2Cdk.Gs2Distributor.Model.Options.NamespaceOptions
{
assumeUserId = "grn:gs2::YourOwnerId:identifier:user:user-0001",
logSetting = new Gs2Cdk.Core.Model.LogSetting(
loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import distributor from "@/gs2cdk/distributor";
class SampleStack extends core.Stack
{
public constructor() {
super();
new distributor.model.Namespace(
this,
"namespace-0001",
{
assumeUserId: "grn:gs2::YourOwnerId:identifier:user:user-0001",
logSetting: new core.LogSetting(
"grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
}
);
}
}
console.log(new SampleStack().yaml()); // Generate Templatefrom gs2_cdk import Stack, core, distributor
class SampleStack(Stack):
def __init__(self):
super().__init__()
distributor.Namespace(
stack=self,
name='namespace-0001',
options=distributor.NamespaceOptions(
assume_user_id='grn:gs2::YourOwnerId:identifier:user:user-0001',
log_setting=core.LogSetting(
logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
),
),
)
print(SampleStack().yaml()) # Generate TemplateTransactionSetting
Transaction Settings
Transaction Settings control how transactions are executed, their consistency, asynchronous processing, and conflict avoidance mechanisms. Combining features like AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, and asynchronous Acquire Actions via GS2-JobQueue enables robust transaction management tailored to game logic.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| enableAutoRun | bool | false | Whether to automatically execute issued transactions on the server side | |||
| enableAtomicCommit | bool | {enableAutoRun} == true | false | Whether to commit the execution of transactions atomically * Applicable only if enableAutoRun is true | ||
| transactionUseDistributor | bool | {enableAtomicCommit} == true | false | Whether to execute transactions asynchronously * Applicable only if enableAtomicCommit is true | ||
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | false | Whether to execute the commit processing of the script result asynchronously * Applicable only if transactionUseDistributor is true | ||
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | false | Whether to use GS2-JobQueue to execute the acquire action * Applicable only if enableAtomicCommit is true | ||
| distributorNamespaceId | string | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor Namespace GRN used to execute transactions | ||
| queueNamespaceId | string | “grn:gs2:{region}:{ownerId}:queue:default” | ~ 1024 chars | GS2-JobQueue Namespace GRN used to execute transactions |
NotificationSetting
Push Notification Settings
This is a setting for sending push notifications when an event occurs in a GS2 microservice. The push notification here refers to the processing via the WebSocket interface provided by GS2-Gateway, and is different from the push notification of a smartphone. For example, when a matchmaking is completed or a friend request is received, the GS2-Gateway can send a push notification via the WebSocket interface, and the game client can detect the change of the state.
GS2-Gateway’s push notifications can be used to forward notifications to mobile push notification services when the destination device is offline. By properly utilizing mobile push notifications, you can implement a flow in which players are notified even if they exit the game during matchmaking and later return to it.
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| gatewayNamespaceId | string | “grn:gs2:{region}:{ownerId}:gateway:default” | ~ 1024 chars | GS2-Gateway namespace to use for push notifications Specify the GS2-Gateway namespace ID in GRN format starting with “grn:gs2:”. | ||||||||
| enableTransferMobileNotification | bool? | false | Whether to forward the notification as a mobile push notification When this notification is sent and the destination device is offline, specify whether to forward it as a mobile push notification. | |||||||||
| sound | string | {enableTransferMobileNotification} == true | ~ 1024 chars | Sound file name to be used for mobile push notifications The sound file name specified here is used when sending mobile push notifications, and you can send notifications with a special sound. * Applicable only if enableTransferMobileNotification is true | ||||||||
| enable | String Enum enum { “Enabled”, “Disabled” } | “Enabled” | Whether to enable push notifications
|
LogSetting
Log Output Settings
Manages log output setting. This type holds the identifier of the log namespace used to output log data. The log namespace ID specifies the GS2-Log namespace to aggregate and store the log data. Through this setting, API request and response log data under this namespace will be output to the target GS2-Log. GS2-Log provides logs in real time, which can be used for system monitoring, analysis, debugging, etc.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024 chars | GS2-Log namespace GRN
to output logs Must be specified in GRN format starting with “grn:gs2:”. |
CurrentDistributorMaster
Currently active Distributor Model master data
This master data describes the definitions of Distributor Models currently active within the namespace. GS2 uses JSON format files for managing master data. By uploading these files, the master data settings are updated on the server.
To create JSON files, GS2 provides a master data editor within the management console. Additionally, you can create tools better suited for game operations and export JSON files in the appropriate format.
Note
Please refer to GS2-Distributor Master Data Reference for the JSON file format.Request
Resource creation and update requests
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| mode | String Enum enum { “direct”, “preUpload” } | “direct” | Update mode
| |||||||||
| settings | string | {mode} == “direct” | ✓* | ~ 5242880 chars | Master Data * Required if mode is “direct” | |||||||
| uploadToken | string | {mode} == “preUpload” | ✓* | ~ 1024 chars | Token obtained by pre-upload Used to apply the uploaded master data. * Required if mode is “preUpload” |
GetAttr
Resource creation results that can be retrieved using the !GetAttr tag
| Type | Description | |
|---|---|---|
| Item | CurrentDistributorMaster | Updated master data of the currently active Distributor Models |
Implementation Example
Type: GS2::Distributor::CurrentDistributorMaster
Properties:
NamespaceName: namespace-0001
Mode: direct
Settings: {
"version": "2019-03-01",
"distributorModels": [
{
"name": "basic",
"metadata": "BASIC",
"inboxNamespaceId": "grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001"
},
{
"name": "special",
"metadata": "SPECIAL",
"inboxNamespaceId": "grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001",
"whiteListTargetIds": [
"test"
]
}
]
}
UploadToken: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/distributor"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
distributor.NewNamespace(
&SampleStack,
"namespace-0001",
distributor.NamespaceOptions{},
).MasterData(
[]distributor.DistributorModel{
distributor.NewDistributorModel(
"basic",
distributor.DistributorModelOptions{
Metadata: pointy.String("BASIC"),
InboxNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001"),
},
),
distributor.NewDistributorModel(
"special",
distributor.DistributorModelOptions{
Metadata: pointy.String("SPECIAL"),
InboxNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001"),
WhiteListTargetIds: []string{
"test",
},
},
),
},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
(new \Gs2Cdk\Distributor\Model\Namespace_(
stack: $this,
name: "namespace-0001"
))->masterData(
[
new \Gs2Cdk\Distributor\Model\DistributorModel(
name:"basic",
options: new \Gs2Cdk\Distributor\Model\Options\DistributorModelOptions(
metadata:"BASIC",
inboxNamespaceId:"grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001"
)
),
new \Gs2Cdk\Distributor\Model\DistributorModel(
name:"special",
options: new \Gs2Cdk\Distributor\Model\Options\DistributorModelOptions(
metadata:"SPECIAL",
inboxNamespaceId:"grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001",
whiteListTargetIds:[
"test",
]
)
)
]
);
}
}
print((new SampleStack())->yaml()); // Generate Templateclass SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.distributor.model.Namespace(
this,
"namespace-0001"
).masterData(
Arrays.asList(
new io.gs2.cdk.distributor.model.DistributorModel(
"basic",
new io.gs2.cdk.distributor.model.options.DistributorModelOptions()
.withMetadata("BASIC")
.withInboxNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001")
),
new io.gs2.cdk.distributor.model.DistributorModel(
"special",
new io.gs2.cdk.distributor.model.options.DistributorModelOptions()
.withMetadata("SPECIAL")
.withInboxNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001")
.withWhiteListTargetIds(Arrays.asList(
"test"
))
)
)
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Distributor.Model.Namespace(
stack: this,
name: "namespace-0001"
).MasterData(
new Gs2Cdk.Gs2Distributor.Model.DistributorModel[] {
new Gs2Cdk.Gs2Distributor.Model.DistributorModel(
name: "basic",
options: new Gs2Cdk.Gs2Distributor.Model.Options.DistributorModelOptions
{
metadata = "BASIC",
inboxNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001"
}
),
new Gs2Cdk.Gs2Distributor.Model.DistributorModel(
name: "special",
options: new Gs2Cdk.Gs2Distributor.Model.Options.DistributorModelOptions
{
metadata = "SPECIAL",
inboxNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001",
whiteListTargetIds = new string[]
{
"test"
}
}
)
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import distributor from "@/gs2cdk/distributor";
class SampleStack extends core.Stack
{
public constructor() {
super();
new distributor.model.Namespace(
this,
"namespace-0001",
).masterData(
[
new distributor.model.DistributorModel(
"basic",
{
metadata: "BASIC",
inboxNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001"
}
),
new distributor.model.DistributorModel(
"special",
{
metadata: "SPECIAL",
inboxNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001",
whiteListTargetIds: [
"test",
]
}
)
]
);
}
}
console.log(new SampleStack().yaml()); // Generate Templatefrom gs2_cdk import Stack, core, distributor
class SampleStack(Stack):
def __init__(self):
super().__init__()
distributor.Namespace(
stack=self,
name="namespace-0001",
).master_data(
distributor_models=[
distributor.DistributorModel(
name='basic',
options=distributor.DistributorModelOptions(
metadata = 'BASIC',
inbox_namespace_id = 'grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001'
),
),
distributor.DistributorModel(
name='special',
options=distributor.DistributorModelOptions(
metadata = 'SPECIAL',
inbox_namespace_id = 'grn:gs2:ap-northeast-1:YourOwnerId:inbox:inbox-0001',
white_list_target_ids = [
'test',
]
),
),
],
)
print(SampleStack().yaml()) # Generate TemplateDistributorModel
Distributor Model
Distributor Model is an entity that defines the policy applied when acquiring resources beyond the inventory capacity. By processing acquisitions through GS2-Distributor, overflow resources can be forwarded as GS2-Inbox messages.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| distributorModelId | string | * | ~ 1024 chars | Distributor Model GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Distributor Model name Distributor Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||
| inboxNamespaceId | string | ~ 1024 chars | GS2-Inbox namespace GRN
to transfer overflow resources When a resource acquisition exceeds the player’s inventory capacity, the overflow resources are forwarded as a message to the specified GS2-Inbox namespace. The player can then claim the resources from their inbox at a later time. | |||
| whiteListTargetIds | List<string> | [] | 0 ~ 1000 items | Whitelist of target resources GRN that can be processed through GS2-Distributor Specify the GRN prefix of the target resources that can be processed for acquisition using this Distributor Model. |