GS2-Ranking GS2-Deploy/CDK リファレンス
エンティティ
Deploy処理で操作する対象リソース
Namespace
ネームスペース
ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。
GS2 の各サービスはネームスペース単位で管理されます。ネームスペースが異なれば、同じサービスでも完全に独立したデータ空間として扱われます。
そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| namespaceId | string | ✓* | ~ 1024文字 | ネームスペース
GRN ※ サーバー側で自動的に設定 | ||
| name | string | ✓ | ~ 128文字 | ネームスペース名 | ||
| description | string | ~ 1024文字 | 説明文 | |||
| transactionSetting | TransactionSetting | トランザクション設定 | ||||
| lastCalculatedAts | List<CalculatedAt> | [] | 0 ~ 1000 items | 最終集計日時リスト | ||
| logSetting | LogSetting | ログの出力設定 | ||||
| createdAt | long | ✓* | 現在時刻 | 作成日時 UNIX 時間・ミリ秒 ※ サーバー側で自動的に設定 | ||
| updatedAt | long | ✓* | 現在時刻 | 最終更新日時 UNIX 時間・ミリ秒 ※ サーバー側で自動的に設定 | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | リビジョン |
GetAttr
!GetAttrタグで取得可能なリソースの生成結果
| 型 | 説明 | |
|---|---|---|
| Item | Namespace | 作成したネームスペース |
実装例
Type: GS2::Ranking::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/ranking"
)
SampleStack := core.NewStack()
ranking.NewNamespace(
&SampleStack,
"namespace-0001",
ranking.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\Ranking\Model\Namespace_(
stack: $this,
name: "namespace-0001",
options: new \Gs2Cdk\Ranking\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.ranking.model.Namespace(
this,
"namespace-0001",
new io.gs2.cdk.ranking.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.Gs2Ranking.Model.Namespace(
stack: this,
name: "namespace-0001",
options: new Gs2Cdk.Gs2Ranking.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 ranking from "@/gs2cdk/ranking";
class SampleStack extends core.Stack
{
public constructor() {
super();
new ranking.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, ranking
class SampleStack(Stack):
def __init__(self):
super().__init__()
ranking.Namespace(
stack=self,
name='namespace-0001',
options=ranking.NamespaceOptions(
log_setting=core.LogSetting(
logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
),
),
)
print(SampleStack().yaml()) # Generate TemplateTransactionSetting
トランザクション設定
トランザクション設定は、トランザクションの実行方法・整合性・非同期処理・競合回避の仕組みを制御する設定です。
自動実行(AutoRun)、アトミック実行(AtomicCommit)、非同期実行(Distributor)、スクリプト結果の一括適用、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
ログの書き出し設定
ログデータの書き出し設定を管理します。この型は、ログデータを書き出すために使用される GS2-Log 名前空間の識別子(Namespace ID)を保持します。
ログ名前空間ID(loggingNamespaceId)には、ログデータを収集し保存する GS2-Log の名前空間を、GRNの形式で指定します。
この設定をすることで、設定された名前空間内で発生したAPIリクエスト・レスポンスのログデータが、対象の GS2-Log 名前空間側へ出力されるようになります。
GS2-Log ではリアルタイムでログが提供され、システムの監視や分析、デバッグなどに利用できます。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024文字 | ログを出力する GS2-Log のネームスペース
GRN 「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。 |
CalculatedAt
最終集計日時
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| categoryName | string | ✓ | ~ 128文字 | カテゴリ名 | ||
| calculatedAt | long | ✓ | 集計日時 |
CurrentRankingMaster
現在有効なマスターデータ
GS2ではマスターデータの管理にJSON形式のファイルを使用します。
ファイルをアップロードすることで、実際にサーバーに設定を反映することができます。
JSONファイルを作成する方法として、マネージメントコンソール内にマスターデータエディタを提供しています。
また、よりゲームの運営に相応しいツールを作成し、適切なフォーマットのJSONファイルを書き出すことでもサービスを利用可能です。
Note
JSONファイルの形式については GS2-Ranking マスターデータリファレンス をご参照ください。| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| namespaceId | string | ✓* | ~ 1024文字 | ネームスペース
GRN ※ サーバー側で自動的に設定 | ||
| settings | string | ✓ | ~ 5242880 バイト (5MB) | マスターデータ |
GetAttr
!GetAttrタグで取得可能なリソースの生成結果
| 型 | 説明 | |
|---|---|---|
| Item | CurrentRankingMaster | 更新した現在有効なマスターデータ |
実装例
Type: GS2::Ranking::CurrentRankingMaster
Properties:
NamespaceName: namespace-0001
Mode: direct
Settings: {
"version": "2019-09-17",
"categories": []
}
UploadToken: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/ranking"
)
SampleStack := core.NewStack()
ranking.NewNamespace(
&SampleStack,
"namespace-0001",
ranking.NamespaceOptions{},
).MasterData(
[]ranking.CategoryModel{
},
)
println(SampleStack.Yaml()) // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
(new \Gs2Cdk\Ranking\Model\Namespace_(
stack: $this,
name: "namespace-0001"
))->masterData(
[
]
);
}
}
print((new SampleStack())->yaml()); // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.ranking.model.Namespace(
this,
"namespace-0001"
).masterData(
Arrays.asList(
)
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Ranking.Model.Namespace(
stack: this,
name: "namespace-0001"
).MasterData(
new Gs2Cdk.Gs2Ranking.Model.CategoryModel[] {
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import ranking from "@/gs2cdk/ranking";
class SampleStack extends core.Stack
{
public constructor() {
super();
new ranking.model.Namespace(
this,
"namespace-0001",
).masterData(
[
]
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
from gs2_cdk import Stack, core, ranking
class SampleStack(Stack):
def __init__(self):
super().__init__()
ranking.Namespace(
stack=self,
name="namespace-0001",
).master_data(
categories=[
],
)
print(SampleStack().yaml()) # Generate TemplateCategoryModel
カテゴリーモデル
カテゴリ毎に異なるランキングを作成できます。
カテゴリには登録できるスコアの最小値・最大値を設定でき、その範囲外のスコアは破棄されます。
ランキングを集計する際にスコアを小さいものを上位(昇順)にするか、大きいものを上位(降順)にするかを設定できます。
ランキングの種類として グローバル と スコープ を選択できます。
グローバルは全プレイヤーが同じ結果を参照するもので、スコープはフレンド内ランキングや、ギルド内ランキングのようなゲームプレイヤー毎に結果の異なるランキングです。
グローバルランキングはカテゴリごとにランキングの集計間隔を15分~24時間で設定できます。
スコープランキングはリアルタイムで集計結果が反映されます。
ランキングデータには世代という設定があり、世代を変更することで登録されたスコアをリセットすることができます。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| categoryModelId | string | ✓* | ~ 1024文字 | カテゴリ
GRN ※ サーバー側で自動的に設定 | ||||||||
| name | string | ✓ | ~ 128文字 | カテゴリ名 | ||||||||
| metadata | string | ~ 1024文字 | メタデータ | |||||||||
| minimumValue | long | 0 ~ 9223372036854775805 | スコアの最小値 | |||||||||
| maximumValue | long | 0 ~ 9223372036854775805 | スコアの最大値 | |||||||||
| sum | bool | ✓ | false | 登録を受け付けたスコアを合算し、合計値を競う | ||||||||
| orderDirection | 文字列列挙型 enum { “asc”, “desc” } | ✓ | スコアのソート方向
| |||||||||
| scope | 文字列列挙型 enum { “global”, “scoped” } | ✓ | ランキングの種類
| |||||||||
| globalRankingSetting | GlobalRankingSetting | {scope} == “global” | ✓* | グローバルランキング設定 ※ scope が “global” であれば 必須 | ||||||||
| entryPeriodEventId | string | ~ 1024文字 | スコアの登録可能期間 GS2-Schedule イベント GRN | |||||||||
| accessPeriodEventId | string | ~ 1024文字 | ランキングデータへのアクセス可能期間 GS2-Schedule イベント GRN |
Scope
集計スコープ
グローバルランキングモードで使用可能。
通常グローバルランキングは登録されたスコア全てを対象にランキングの集計が行われます。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128文字 | スコープ名 | ||
| targetDays | long | ✓ | 1 ~ 365 | 集計対象日数 |
GlobalRankingSetting
グローバルランキング設定
グローバルは全プレイヤーが同じ結果を参照するものです。
ランキングの集計間隔を15分~24時間で設定できます。
ランキングデータには世代という設定があり、世代を変更することで登録されたスコアをリセットすることができます。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| uniqueByUserId | bool | ✓ | true | ユーザーID毎にスコアを1つしか登録されないようにする | ||
| calculateIntervalMinutes | int | ✓ | 15 ~ 1440 | スコアの集計間隔(分) | ||
| calculateFixedTiming | FixedTiming | スコアの固定集計開始時刻 | ||||
| additionalScopes | List<Scope> | 0 ~ 10 items | スコープリスト | |||
| ignoreUserIds | List<string> | 0 ~ 10000 items | ランキングに反映しないユーザーIDリスト | |||
| generation | string | ~ 256文字 | ランキングの世代 |
FixedTiming
集計時刻固定設定
グローバルランキングの集計タイミングを固定するための設定です。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |
|---|---|---|---|---|---|---|
| hour | int | 0 ~ 23 | スコアの固定集計開始時刻(時) | |||
| minute | int | 0 ~ 59 | スコアの固定集計開始時刻(分) |