GS2-Enhance GS2-Deploy/CDK リファレンス

エンティティ

Namespace

ネームスペース

ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。 GS2 のサービスは基本的にネームスペースというレイヤーがあり、ネームスペースが異なれば同じサービスでもまったく別のデータ空間として取り扱われます。

そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。

必須デフォルト値の制限説明
namestring~ 32文字ネームスペース名
descriptionstring~ 1024文字説明文
enableDirectEnhanceboolfalseDirectEnhance を利用できるようにするか
transactionSettingTransactionSettingトランザクション設定
enhanceScriptScriptSetting強化時に実行するスクリプト
logSettingLogSettingログの出力設定

GetAttr

説明
ItemNamespace作成したネームスペース

実装例

Type: GS2::Enhance::Namespace
Properties:
  Name: namespace1
  Description: null
  EnableDirectEnhance: true
  TransactionSetting: 
    EnableAutoRun: false
    QueueNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001
    KeyId: grn:gs2:ap-northeast-1:YourOwnerId:key:namespace1:key:key-0001
  EnhanceScript: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1
from gs2_cdk import Stack, core, enhance

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        enhance.Namespace(
            stack=self,
            name="namespace-0001",
            options=enhance.NamespaceOptions(
                enable_direct_enhance=True,
                transaction_setting=core.TransactionSetting(
                    enable_auto_run=False,
                    distributor_namespace_id=,
                    queue_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001',
                    options=core.TransactionSettingOptions(
                        key_id='grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001',
                    )
                ),
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        )

print(SampleStack().yaml())  # Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        new \Gs2Cdk\Enhance\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            options: new \Gs2Cdk\Enhance\Model\Options\NamespaceOptions(
                enableDirectEnhance: True,
                transactionSetting: new \Gs2Cdk\Core\Model\TransactionSetting(
                    enableAutoRun: False,
                    distributorNamespaceId: ,
                    queueNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001",
                    options: new \Gs2Cdk\Core\Model\Options\TransactionSettingOptions(
                        keyId: "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001",
                    )
                ),
                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.enhance.model.Namespace(
            this,
            "namespace-0001",
            new io.gs2.cdk.enhance.model.options.NamespaceOptions() {
                {
                    enableDirectEnhance = true;
                    transactionSetting = new io.gs2.cdk.core.model.TransactionSetting(
                        false,
                        ,
                        "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001",
                        new io.gs2.cdk.core.model.options.TransactionSettingOptions(
                            "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
                        )
                    );
                    logSetting = new io.gs2.cdk.core.model.LogSetting(
                        "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                    );
                }
            }
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
import core from "@/gs2cdk/core";
import enhance from "@/gs2cdk/enhance";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new enhance.model.Namespace(
            this,
            "namespace-0001",
            {
                enableDirectEnhance: true,
                transactionSetting: new core.TransactionSetting(
                    false,
                    ,
                    "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001",
                    {
                        "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
                    }
                ),
                logSetting: new core.LogSetting(
                    "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Enhance.Model.Namespace(
            this,
            "namespace-0001",
            new Gs2Cdk.Gs2Enhance.Model.Options.NamespaceOptions {
                enableDirectEnhance = true,
                transactionSetting = new Gs2Cdk.Core.Model.TransactionSetting(
                    false,
                    ,
                    "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001",
                    new Gs2Cdk.Core.Model.Options.TransactionSettingOptions(
                        KeyId = "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
                    }
                ),
                logSetting = new Gs2Cdk.Core.Model.LogSetting(
                    "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                ),
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template

CurrentRateMaster

現在有効な強化レートマスター

GS2ではマスターデータの管理にJSON形式のファイルを使用します。 ファイルをアップロードすることで、実際にサーバーに設定を反映することができます。

JSONファイルを作成する方法として、マネージメントコンソール上でのマスターデータエディタを提供していますが よりゲームの運営に相応しいツールを作成し、適切なフォーマットのJSONファイルを書き出すことでもサービスを利用可能です。

JSONファイルの形式についてはドキュメントを参照ください。

必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
settingsstring~ 5242880文字マスターデータ

GetAttr

説明
ItemCurrentRateMaster更新した現在有効な強化レート設定

実装例

Type: GS2::Enhance::CurrentRateMaster
Properties:
  NamespaceName: namespace1
  Settings: {
    "version": "2020-08-22",
    "rateModels": [
      {
        "name": "character-friendly",
        "metadata": "CHARACTER_FRIENDLY",
        "targetInventoryModelId": "grn:inventory:character",
        "acquireExperienceSuffix": ":friendly",
        "materialInventoryModelId": "grn:inventory:sweet",
        "acquireExperienceHierarchy": [
          "taste"
        ],
        "experienceModelId": "grn:experience:friendly",
        "bonusRates": [
          {
            "rate": 1,
            "weight": 90
          }
        ]
      },
      {
        "name": "character-level",
        "metadata": "CHARACTER_LEVEL",
        "targetInventoryModelId": "grn:inventory:character",
        "acquireExperienceSuffix": ":level",
        "materialInventoryModelId": "grn:inventory:material",
        "acquireExperienceHierarchy": [
          "experience"
        ],
        "experienceModelId": "grn:experience:level",
        "bonusRates": [
          {
            "rate": 1,
            "weight": 90
          },
          {
            "rate": 1.5,
            "weight": 9
          },
          {
            "rate": 2,
            "weight": 1
          }
        ]
      }
    ],
    "unleashRateModels": []
  }
from gs2_cdk import Stack, core, enhance

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        enhance.Namespace(
            stack=self,
            # 省略
        ).master_data(
            [
                enhance.RateModel(
                    name='character-friendly',
                    target_inventory_model_id='grn:inventory:character',
                    acquire_experience_suffix=':friendly',
                    material_inventory_model_id='grn:inventory:sweet',
                    experience_model_id='grn:experience:friendly',
                    options=enhance.RateModelOptions(
                        metadata='CHARACTER_FRIENDLY',
                        acquire_experience_hierarchy=[    'taste',
                            ],
                        bonus_rates=[    {'rate': 1, 'weight': 90},
                            ],
                    ),
                ),
                enhance.RateModel(
                    name='character-level',
                    target_inventory_model_id='grn:inventory:character',
                    acquire_experience_suffix=':level',
                    material_inventory_model_id='grn:inventory:material',
                    experience_model_id='grn:experience:level',
                    options=enhance.RateModelOptions(
                        metadata='CHARACTER_LEVEL',
                        acquire_experience_hierarchy=[    'experience',
                            ],
                        bonus_rates=[    {'rate': 1, 'weight': 90},
                            {'rate': 1.5, 'weight': 9},
                            {'rate': 2, 'weight': 1},
                            ],
                    ),
                ),
            ],
            [
            ],
        )

print(SampleStack().yaml())  # Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Enhance\Model\Namespace_(
            stack: $this,
            // 省略
        ))->masterData(
            [
                new \Gs2Cdk\Enhance\Model\RateModel(
                    name:"character-friendly",
                    targetInventoryModelId:"grn:inventory:character",
                    acquireExperienceSuffix:":friendly",
                    materialInventoryModelId:"grn:inventory:sweet",
                    experienceModelId:"grn:experience:friendly",
                    options: new \Gs2Cdk\Enhance\Model\Options\RateModelOptions(
                        metadata:"CHARACTER_FRIENDLY",
                        acquireExperienceHierarchy:[    "taste",
                        ],
                        bonusRates:[    {'rate': 1, 'weight': 90},
                        ],
                    ),
                ),
                new \Gs2Cdk\Enhance\Model\RateModel(
                    name:"character-level",
                    targetInventoryModelId:"grn:inventory:character",
                    acquireExperienceSuffix:":level",
                    materialInventoryModelId:"grn:inventory:material",
                    experienceModelId:"grn:experience:level",
                    options: new \Gs2Cdk\Enhance\Model\Options\RateModelOptions(
                        metadata:"CHARACTER_LEVEL",
                        acquireExperienceHierarchy:[    "experience",
                        ],
                        bonusRates:[    {'rate': 1, 'weight': 90},
                        {'rate': 1.5, 'weight': 9},
                        {'rate': 2, 'weight': 1},
                        ],
                    ),
                ),
            ],
            [
            ],
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.enhance.model.Namespace(
            this,
            // 省略
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.enhance.model.RateModel(
                    "character-friendly",
                    "grn:inventory:character",
                    ":friendly",
                    "grn:inventory:sweet",
                    "grn:experience:friendly",
                    new io.gs2.cdk.enhance.model.options.RateModelOptions() {
                        {
                            metadata: "CHARACTER_FRIENDLY";
                            acquireExperienceHierarchy: Arrays.asList(
                                "taste"
                            );
                            bonusRates: Arrays.asList(
                                {'rate': 1, 'weight': 90}
                            );
                        }
                    }
                ),
                new io.gs2.cdk.enhance.model.RateModel(
                    "character-level",
                    "grn:inventory:character",
                    ":level",
                    "grn:inventory:material",
                    "grn:experience:level",
                    new io.gs2.cdk.enhance.model.options.RateModelOptions() {
                        {
                            metadata: "CHARACTER_LEVEL";
                            acquireExperienceHierarchy: Arrays.asList(
                                "experience"
                            );
                            bonusRates: Arrays.asList(
                                {'rate': 1, 'weight': 90},
                            {'rate': 1.5, 'weight': 9},
                            {'rate': 2, 'weight': 1}
                            );
                        }
                    }
                )
            ),
            Arrays.asList(
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
import core from "@/gs2cdk/core";
import enhance from "@/gs2cdk/enhance";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new enhance.model.Namespace(
            this,
            // 省略
        ).masterData(
            [
                new enhance.model.RateModel(
                    "character-friendly",
                    "grn:inventory:character",
                    ":friendly",
                    "grn:inventory:sweet",
                    "grn:experience:friendly",
                    {
                        metadata: "CHARACTER_FRIENDLY",
                        acquireExperienceHierarchy: [
                                "taste"
                            ],
                        bonusRates: [
                                {'rate': 1, 'weight': 90}
                            ]
                    }
                ),
                new enhance.model.RateModel(
                    "character-level",
                    "grn:inventory:character",
                    ":level",
                    "grn:inventory:material",
                    "grn:experience:level",
                    {
                        metadata: "CHARACTER_LEVEL",
                        acquireExperienceHierarchy: [
                                "experience"
                            ],
                        bonusRates: [
                                {'rate': 1, 'weight': 90},
                            {'rate': 1.5, 'weight': 9},
                            {'rate': 2, 'weight': 1}
                            ]
                    }
                )
            ],
            [
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Enhance.Model.Namespace(
            this,
            // 省略
        ).MasterData(
            new [] {
                new Gs2Cdk.Gs2Enhance.Model.RateModel(
                    "character-friendly",
                    "grn:inventory:character",
                    ":friendly",
                    "grn:inventory:sweet",
                    "grn:experience:friendly",
                    new Gs2Cdk.Gs2Enhance.Model.Options.RateModelOptions {
                        metadata = "CHARACTER_FRIENDLY",
                        acquireExperienceHierarchy = new string[] {
                            "taste"
                        },
                        bonusRates = new Gs2Cdk.Gs2Enhance.Model.BonusRate[] {
                            {'rate': 1, 'weight': 90}
                        },
                    }
                ),
                new Gs2Cdk.Gs2Enhance.Model.RateModel(
                    "character-level",
                    "grn:inventory:character",
                    ":level",
                    "grn:inventory:material",
                    "grn:experience:level",
                    new Gs2Cdk.Gs2Enhance.Model.Options.RateModelOptions {
                        metadata = "CHARACTER_LEVEL",
                        acquireExperienceHierarchy = new string[] {
                            "experience"
                        },
                        bonusRates = new Gs2Cdk.Gs2Enhance.Model.BonusRate[] {
                            {'rate': 1, 'weight': 90},
                        {'rate': 1.5, 'weight': 9},
                        {'rate': 2, 'weight': 1}
                        },
                    }
                )
            },
            new [] {
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template

BonusRate

経験値獲得量ボーナス

必須デフォルト値の制限説明
ratefloat1.0~ 10000経験値ボーナスの倍率(1.0=ボーナスなし)
weightint1~ 2147483645抽選重み

Material

強化素材

必須デフォルト値の制限説明
materialItemSetIdstring~ 1024文字有効期限ごとのアイテム所持数量GRN
countint1~ 2147483645消費数量

UnleashRateEntryModel

限界突破レートエントリモデル

必須デフォルト値の制限説明
gradeValuelong1 ~ 1000対象グレード
needCountint1 ~ 1000同種のアイテムを何個消費するか

Config

コンフィグ設定

スタンプシートの変数に適用する設定値

必須デフォルト値の制限説明
keystring~ 64文字名前
valuestring~ 51200文字

GitHubCheckoutSetting

GitHubからマスターデータをチェックアウトする設定

必須デフォルト値の制限説明
apiKeyIdstring~ 1024文字GitHub のAPIキーGRN
repositoryNamestring~ 1024文字リポジトリ名
sourcePathstring~ 1024文字ソースコードのファイルパス
referenceTypeenum [
“commit_hash”,
“branch”,
“tag”
]
~ 128文字コードの取得元
commitHashstring{referenceType} == “commit_hash”~ 1024文字コミットハッシュ
branchNamestring{referenceType} == “branch”~ 1024文字ブランチ名
tagNamestring{referenceType} == “tag”~ 1024文字タグ名

ScriptSetting

スクリプト設定

GS2 ではマイクロサービスのイベントに関連づけて、カスタムスクリプトを実行することができます。 このモデルは、スクリプトの実行をトリガーするための設定を保持します。

スクリプトの実行方式は大きく2種類あり、それは「同期実行」と「非同期実行」です。 同期実行は、スクリプトの実行が完了するまで処理がブロックされます。 かわりに、スクリプトの実行結果を使ってAPIの実行を止めたり、APIの結果を改ざんすることができます。

一方、非同期実行は、スクリプトの実行が完了するまで処理がブロックされません。 かわりに、スクリプトの実行結果を使ってAPIの実行を止めたり、APIの結果を改ざんすることはできません。 しかし、非同期実行は、スクリプトの実行が完了するまで処理がブロックされないため、APIの応答に影響を与えないため、原則非同期実行を使用することをおすすめします。

非同期実行には実行方式が2種類あり、GS2-Script と Amazon EventBridge があります。 Amazon EventBridge を使用することで、Lua 以外の言語で処理を記述することができます。

必須デフォルト値の制限説明
triggerScriptIdstring~ 1024文字スクリプトGRN
doneTriggerTargetTypeenum [
“none”,
“gs2_script”,
“aws”
]
“none”~ 128文字完了通知の通知先
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024文字スクリプトGRN
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024文字ネームスペースGRN

LogSetting

ログの書き出し設定

ログデータの書き出し設定を管理します。この型は、ログデータを書き出すために使用されるログ名前空間の識別子(Namespace ID)を保持します。 ログ名前空間IDは、ログデータを集約し、保存する対象の GS2-Log の名前空間を指定します。 この設定を通じて、この名前空間以下のAPIリクエスト・レスポンスログデータが対象の GS2-Log へ出力されるようになります。 GS2-Log にはリアルタイムでログが提供され、システムの監視や分析、デバッグなどに利用できます。

必須デフォルト値の制限説明
loggingNamespaceIdstring~ 1024文字ネームスペースGRN

TransactionSetting

トランザクション設定

必須デフォルト値の制限説明
enableAutoRunboolfalse発行したスタンプシートをサーバーサイドで自動的に実行するか
distributorNamespaceIdstring“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024文字スタンプシートの実行に使用する GS2-Distributor ネームスペース
keyIdstring!{enableAutoRun}“grn:gs2:{region}:{ownerId}:key:default:key:default”~ 1024文字スタンプシートの署名に使用する GS2-Key の暗号鍵
queueNamespaceIdstring“grn:gs2:{region}:{ownerId}:queue:default”~ 1024文字スタンプシートの実行に使用する GS2-JobQueue のネームスペース