GS2-Distributor Deploy/CDK リファレンス
エンティティ
Deploy処理で操作する対象リソース
Namespace
ネームスペース
ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。
GS2 の各サービスはネームスペース単位で管理されます。ネームスペースが異なれば、同じサービスでも完全に独立したデータ空間として扱われます。
そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。
Request
リソースの生成リクエスト
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128文字 | ネームスペース名 ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 | ||
| description | string | ~ 1024文字 | 説明文 | |||
| transactionSetting | TransactionSetting | トランザクション設定 | ||||
| assumeUserId | string | ~ 1024文字 | GS2-Identifier ユーザーGRN | |||
| autoRunStampSheetNotification | NotificationSetting | ✓ | トランザクションの自動実行が完了したときのプッシュ通知(旧仕様) | |||
| autoRunTransactionNotification | NotificationSetting | ✓ | トランザクションの自動実行が完了したときのプッシュ通知 | |||
| logSetting | LogSetting | ログの出力設定 |
GetAttr
!GetAttrタグで取得可能なリソースの生成結果
| 型 | 説明 | |
|---|---|---|
| Item | Namespace | 作成したネームスペース |
実装例
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 Template
class 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 Template
class 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 Template
from 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
トランザクション設定
トランザクション設定は、トランザクションの実行方法・整合性・非同期処理・競合回避の仕組みを制御する設定です。
自動実行(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 |
NotificationSetting
プッシュ通知に関する設定
GS2 のマイクロサービス内で何らかのイベントが発生した際に、プッシュ通知を送信するための設定です。
ここでいうプッシュ通知は GS2-Gateway の提供する WebSocket インターフェースを経由した処理であり、スマートフォンのプッシュ通知とは性質が異なります。
たとえば、マッチメイキングが完了した時やフレンドリクエストが届いた時など、ゲームクライアントの操作とは関係なく状態が変化した際に GS2-Gateway を経由してプッシュ通知をすることで、ゲームクライアントは状態の変化を検知することができます。
GS2-Gateway のプッシュ通知は通知先のデバイスがオフラインだった時に追加の処理としてモバイルプッシュ通知を送信できます。
モバイルプッシュ通知をうまく利用すれば、マッチメイキング中にゲームを終了しても、モバイルプッシュ通知を使用してプレイヤーに通知し、ゲームに戻ってくるフローを実現できる可能性があります。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| gatewayNamespaceId | string | ✓ | “grn:gs2:{region}:{ownerId}:gateway:default” | ~ 1024文字 | プッシュ通知に使用する GS2-Gateway のネームスペース 「grn:gs2:」から始まる GRN 形式で GS2-Gateway のネームスペースIDを指定します。 | |||||||
| enableTransferMobileNotification | bool? | false | モバイルプッシュ通知へ転送するか この通知を送信しようとした時、通知先のデバイスがオフラインだった場合、モバイルプッシュ通知へ転送するかどうかを指定します。 | |||||||||
| sound | string | {enableTransferMobileNotification} == true | ~ 1024文字 | モバイルプッシュ通知で使用するサウンドファイル名 ここで指定したサウンドファイル名は、モバイルプッシュ通知を送信する際に使用され、特別なサウンドで通知を出すことができます。 ※ enableTransferMobileNotification が true であれば 有効 | ||||||||
| enable | 文字列列挙型 enum { “Enabled”, “Disabled” } | ✓ | “Enabled” | プッシュ通知を有効にするか
|
LogSetting
ログの書き出し設定
ログデータの書き出し設定を管理します。この型は、ログデータを書き出すために使用されるログ名前空間の識別子(Namespace ID)を保持します。
ログ名前空間IDは、ログデータを集約し、保存する対象の GS2-Log の名前空間を指定します。
この設定を通じて、この名前空間以下のAPIリクエスト・レスポンスログデータが対象の GS2-Log へ出力されるようになります。
GS2-Log にはリアルタイムでログが提供され、システムの監視や分析、デバッグなどに利用できます。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024文字 | ログを出力する GS2-Log のネームスペース
GRN 「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。 |
CurrentDistributorMaster
現在アクティブなマスターデータ
現在ネームスペース内で有効な、配信モデルの定義を記述したマスターデータです。
GS2ではマスターデータの管理にJSON形式のファイルを使用します。
ファイルをアップロードすることで、実際にサーバーに設定を反映することができます。
JSONファイルを作成する方法として、マネージメントコンソール内にマスターデータエディタを提供しています。
また、よりゲームの運営に相応しいツールを作成し、適切なフォーマットのJSONファイルを書き出すことでもサービスを利用可能です。
Note
JSONファイルの形式については GS2-Distributor マスターデータリファレンス をご参照ください。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 | CurrentDistributorMaster | 更新した現在アクティブな配信モデルのマスターデータ |
実装例
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 Template
class 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 Template
class 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 Template
from 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
配信モデル
配信モデルとはエンティティの入手時に所持枠を超えて入手した時のポリシーを設定するエンティティです。
GS2-Distributor を通して入手処理を行うことで、あふれたリソースを GS2-Inbox のメッセージとして転送することができます。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| distributorModelId | string | ✓* | ~ 1024文字 | 配信モデル
GRN ※ サーバー側で自動的に設定 | ||
| name | string | ✓ | ~ 128文字 | 配信モデル名 配信モデル固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 | ||
| metadata | string | ~ 2048文字 | メタデータ メタデータには任意の値を設定できます。 これらの値は GS2 の動作には影響しないため、ゲーム内で利用する情報の保存先として使用できます。 | |||
| inboxNamespaceId | string | ~ 1024文字 | あふれたリソースを転送する GS2-Inbox のネームスペース GRN | |||
| whiteListTargetIds | List<string> | [] | 0 ~ 1000 items | GS2-Distributorを通して処理出来る対象のリソースGRNのホワイトリスト この配信モデルを使用して入手処理を行える対象となるリソースのGRNプレフィックスを指定します。 |