GS2-SerialKey Deploy/CDK リファレンス
エンティティ
Deploy処理で操作する対象リソース
Namespace
ネームスペース
ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。
GS2 の各サービスはネームスペース単位で管理されます。ネームスペースが異なれば、同じサービスでも完全に独立したデータ空間として扱われます。
そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。
Request
リソースの生成リクエスト
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128文字 | ネームスペース名 ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 | ||
| description | string | ~ 1024文字 | 説明文 | |||
| transactionSetting | TransactionSetting | トランザクション設定 | ||||
| logSetting | LogSetting | ログの出力設定 |
GetAttr
!GetAttrタグで取得可能なリソースの生成結果
| 型 | 説明 | |
|---|---|---|
| Item | Namespace | 作成したネームスペース |
実装例
Type: GS2::SerialKey::Namespace
Properties:
Name: namespace-0001
Description: null
TransactionSetting: 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/serialKey"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
serialKey.NewNamespace(
&SampleStack,
"namespace-0001",
serialKey.NamespaceOptions{
LogSetting: &core.LogSetting{
LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
},
)
println(SampleStack.Yaml()) // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
new \Gs2Cdk\SerialKey\Model\Namespace_(
stack: $this,
name: "namespace-0001",
options: new \Gs2Cdk\SerialKey\Model\Options\NamespaceOptions(
logSetting: new \Gs2Cdk\Core\Model\LogSetting(
loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
)
);
}
}
print((new SampleStack())->yaml()); // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.serialKey.model.Namespace(
this,
"namespace-0001",
new io.gs2.cdk.serialKey.model.options.NamespaceOptions()
.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.Gs2SerialKey.Model.Namespace(
stack: this,
name: "namespace-0001",
options: new Gs2Cdk.Gs2SerialKey.Model.Options.NamespaceOptions
{
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 serialKey from "@/gs2cdk/serialKey";
class SampleStack extends core.Stack
{
public constructor() {
super();
new serialKey.model.Namespace(
this,
"namespace-0001",
{
logSetting: new core.LogSetting(
"grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
}
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
from gs2_cdk import Stack, core, serial_key
class SampleStack(Stack):
def __init__(self):
super().__init__()
serial_key.Namespace(
stack=self,
name='namespace-0001',
options=serial_key.NamespaceOptions(
log_setting=core.LogSetting(
logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
),
),
)
print(SampleStack().yaml()) # Generate TemplateTransactionSetting
トランザクション設定
トランザクション設定は、トランザクションの実行方法・整合性・非同期処理・競合回避の仕組みを制御する設定です。
自動実行(AutoRun)、アトミック実行(AtomicCommit)、GS2-Distributor を利用した非同期実行、スクリプト結果の一括適用、GS2-JobQueue による入手アクションの非同期化などを組み合わせ、ゲームロジックに応じた堅牢なトランザクション管理を可能にします。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| enableAutoRun | bool | ✓ | false | 発行したトランザクションをサーバーサイドで自動的に実行するか | ||
| enableAtomicCommit | bool | {enableAutoRun} == true | ✓* | false | トランザクションの実行をアトミックにコミットするか ※ enableAutoRun が true であれば 必須 | |
| transactionUseDistributor | bool | {enableAtomicCommit} == true | ✓* | false | トランザクションを非同期処理で実行する ※ enableAtomicCommit が true であれば 必須 | |
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | ✓* | false | スクリプトの結果コミット処理を非同期処理で実行するか ※ transactionUseDistributor が true であれば 必須 | |
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | ✓* | false | 入手アクションを実行する際に GS2-JobQueue を使用するか ※ enableAtomicCommit が true であれば 必須 | |
| distributorNamespaceId | string | ✓ | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024文字 | トランザクションの実行に使用する GS2-Distributor ネームスペース GRN | |
| queueNamespaceId | string | ✓ | “grn:gs2:{region}:{ownerId}:queue:default” | ~ 1024文字 | トランザクションの実行に使用する GS2-JobQueue のネームスペース GRN |
LogSetting
ログの書き出し設定
ログデータの書き出し設定を管理します。この型は、ログデータを書き出すために使用されるログ名前空間の識別子(Namespace ID)を保持します。
ログ名前空間IDは、ログデータを集約し、保存する対象の GS2-Log の名前空間を指定します。
この設定を通じて、この名前空間以下のAPIリクエスト・レスポンスログデータが対象の GS2-Log へ出力されるようになります。
GS2-Log にはリアルタイムでログが提供され、システムの監視や分析、デバッグなどに利用できます。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024文字 | ログを出力する GS2-Log のネームスペース
GRN 「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。 |
CurrentCampaignMaster
現在アクティブなキャンペーンモデルのマスターデータ
現在ネームスペース内で有効な、キャンペーンモデルの定義を記述したマスターデータです。
GS2ではマスターデータの管理にJSON形式のファイルを使用します。
ファイルをアップロードすることで、実際にサーバーに設定を反映することができます。
JSONファイルを作成する方法として、マネージメントコンソール内にマスターデータエディタを提供しています。
また、よりゲームの運営に相応しいツールを作成し、適切なフォーマットのJSONファイルを書き出すことでもサービスを利用可能です。
Note
JSONファイルの形式については GS2-SerialKey マスターデータリファレンス をご参照ください。Request
リソースの生成リクエスト
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128文字 | ネームスペース名 ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 | ||||||||
| mode | 文字列列挙型 enum { “direct”, “preUpload” } | ✓ | “direct” | 更新モード
| ||||||||
| settings | string | {mode} == “direct” | ✓* | ~ 5242880文字 | マスターデータ ※ mode が “direct” であれば必須 | |||||||
| uploadToken | string | {mode} == “preUpload” | ✓* | ~ 1024文字 | 事前アップロードで取得したトークン アップロードしたマスターデータを適用するために使用されます。 ※ mode が “preUpload” であれば必須 |
GetAttr
!GetAttrタグで取得可能なリソースの生成結果
| 型 | 説明 | |
|---|---|---|
| Item | CurrentCampaignMaster | 更新した現在アクティブなキャンペーンモデルのマスターデータ |
実装例
Type: GS2::SerialKey::CurrentCampaignMaster
Properties:
NamespaceName: namespace-0001
Mode: direct
Settings: {
"version": "2022-09-13",
"campaignModels": [
{
"name": "campaign-0001",
"enableCampaignCode": true,
"metadata": "CAMPAIGN_0001"
}
]
}
UploadToken: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/serialKey"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
serialKey.NewNamespace(
&SampleStack,
"namespace-0001",
serialKey.NamespaceOptions{},
).MasterData(
[]serialKey.CampaignModel{
serialKey.NewCampaignModel(
"campaign-0001",
true,
serialKey.CampaignModelOptions{
Metadata: pointy.String("CAMPAIGN_0001"),
},
),
},
)
println(SampleStack.Yaml()) // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
(new \Gs2Cdk\SerialKey\Model\Namespace_(
stack: $this,
name: "namespace-0001"
))->masterData(
[
new \Gs2Cdk\SerialKey\Model\CampaignModel(
name:"campaign-0001",
enableCampaignCode:True,
options: new \Gs2Cdk\SerialKey\Model\Options\CampaignModelOptions(
metadata:"CAMPAIGN_0001"
)
)
]
);
}
}
print((new SampleStack())->yaml()); // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.serialKey.model.Namespace(
this,
"namespace-0001"
).masterData(
Arrays.asList(
new io.gs2.cdk.serialKey.model.CampaignModel(
"campaign-0001",
true,
new io.gs2.cdk.serialKey.model.options.CampaignModelOptions()
.withMetadata("CAMPAIGN_0001")
)
)
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2SerialKey.Model.Namespace(
stack: this,
name: "namespace-0001"
).MasterData(
new Gs2Cdk.Gs2SerialKey.Model.CampaignModel[] {
new Gs2Cdk.Gs2SerialKey.Model.CampaignModel(
name: "campaign-0001",
enableCampaignCode: true,
options: new Gs2Cdk.Gs2SerialKey.Model.Options.CampaignModelOptions
{
metadata = "CAMPAIGN_0001"
}
)
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import serialKey from "@/gs2cdk/serialKey";
class SampleStack extends core.Stack
{
public constructor() {
super();
new serialKey.model.Namespace(
this,
"namespace-0001",
).masterData(
[
new serialKey.model.CampaignModel(
"campaign-0001",
true,
{
metadata: "CAMPAIGN_0001"
}
)
]
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
from gs2_cdk import Stack, core, serial_key
class SampleStack(Stack):
def __init__(self):
super().__init__()
serial_key.Namespace(
stack=self,
name="namespace-0001",
).master_data(
campaign_models=[
serial_key.CampaignModel(
name='campaign-0001',
enable_campaign_code=True,
options=serial_key.CampaignModelOptions(
metadata = 'CAMPAIGN_0001'
),
),
],
)
print(SampleStack().yaml()) # Generate TemplateCampaignModel
キャンペーンモデル
キャンペーンモデルはキャンペーンを定義し、シリアルコードと紐づけて管理するために使用されます。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| campaignId | string | ✓* | ~ 1024文字 | キャンペーンモデル
GRN ※ サーバー側で自動的に設定 | ||
| name | string | ✓ | ~ 128文字 | キャンペーン名 | ||
| metadata | string | ~ 2048文字 | メタデータ メタデータには任意の値を設定できます。 これらの値は GS2 の動作には影響しないため、ゲーム内で利用する情報の保存先として使用できます。 | |||
| enableCampaignCode | bool | ✓ | false | キャンペーンコードでの引き換えを許可するか |