> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-Matchmaking Deploy/CDK リファレンス

GS2-Deployのスタックを作成する際に使用するテンプレートのフォーマットと、CDKによる各種言語のテンプレート出力の実装例




## エンティティ

Deploy処理で操作の対象となるリソース

### Namespace

ネームスペース<br>

ネームスペースは、一つのプロジェクト内で同じサービスを異なる用途で複数利用するためのエンティティです。<br>
GS2 の各サービスはネームスペース単位で管理されます。ネームスペースが異なれば、同じサービスでも完全に独立したデータ空間として扱われます。<br>

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

#### Request

リソースの生成・更新リクエスト

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| name | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| description | string |  | |  |  ~ 1024文字 | 説明文 |
| transactionSetting | [TransactionSetting](#transactionsetting) |  | |  |  | トランザクション設定<br>マッチメイキング操作時のトランザクションの処理方法を制御する設定です。 |
| enableRating | bool |  | | false |  | レーティング計算機能の有効化<br>Glicko-2 ベースのレーティング計算機能を有効にするかどうか。<br>有効にすると、プレイヤーは Vote システムを通じて対戦結果を送信し、レーティングが自動的に更新されます。<br>RatingModel マスターデータの設定が必要です。デフォルトは false です。 |
| enableDisconnectDetection | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"disable",<br>&nbsp;&nbsp;"enable"<br>}<br> |  | | "disable" |  | 切断検知<br>マッチメイキング中のプレイヤーが待機中であることを定期的に報告する必要があるかを制御します。<br>有効にすると、プレイヤーが設定されたタイムアウト期間内にキープアライブを送信しない場合、ギャザリングから自動的に退出処理されます。<br>これにより「ゴースト」プレイヤーがマッチメイキングの完了をブロックすることを防ぎます。デフォルトは "disable" です。"disable": 無効 / "enable": 有効 /  |
| disconnectDetectionTimeoutSeconds | int | {enableDisconnectDetection} == "enable" | ✓※|  | 15 ~ 600 | 切断検知タイムアウト（秒）<br>キープアライブ報告なしにプレイヤーを切断とみなしギャザリングから退出させるまでの待機秒数。<br>切断検知が有効な場合のみ適用されます。15 から 600 秒の範囲で指定します。<br>※ enableDisconnectDetection が "enable" であれば必須 |
| createGatheringTriggerType | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"none",<br>&nbsp;&nbsp;"gs2_realtime",<br>&nbsp;&nbsp;"gs2_script"<br>}<br> |  | | "none" |  | ギャザリング作成時トリガータイプ<br>新しいギャザリングが作成されたときに実行するアクションの種類。<br>GS2-Realtime のルーム作成をトリガーしてリアルタイム通信を開始したり、GS2-Script を実行してカスタムロジックを実行できます。デフォルトは "none" です。"none": なし / "gs2_realtime": GS2-Realtime のルーム作成 / "gs2_script": GS2-Script の実行 /  |
| createGatheringTriggerRealtimeNamespaceId | string | {createGatheringTriggerType} == "gs2_realtime" | ✓※|  |  ~ 1024文字 | ギャザリング作成時にルームを作成する GS2-Realtime のネームスペース<br>※ createGatheringTriggerType が "gs2_realtime" であれば必須 |
| createGatheringTriggerScriptId | string | {createGatheringTriggerType} == "gs2_script" | ✓※|  |  ~ 1024文字 | ギャザリング作成時に実行される GS2-Script のスクリプトGRN<br>Script トリガーリファレンス - [`createGathering`](../script/#creategathering)<br>※ createGatheringTriggerType が "gs2_script" であれば必須 |
| completeMatchmakingTriggerType | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"none",<br>&nbsp;&nbsp;"gs2_realtime",<br>&nbsp;&nbsp;"gs2_script"<br>}<br> |  | | "none" |  | マッチメイキング完了時トリガータイプ<br>マッチメイキングが完了した（すべてのロール枠が埋まった）ときに実行するアクションの種類。<br>マッチングされたプレイヤー向けに GS2-Realtime のルーム作成をトリガーしたり、GS2-Script を実行してカスタムの事後処理ロジックを実行できます。デフォルトは "none" です。"none": なし / "gs2_realtime": GS2-Realtime のルーム作成 / "gs2_script": GS2-Script の実行 /  |
| completeMatchmakingTriggerRealtimeNamespaceId | string | {completeMatchmakingTriggerType} == "gs2_realtime" | ✓※|  |  ~ 1024文字 | マッチメイキング完了時にルームを作成する GS2-Realtime のネームスペースGRN<br>※ completeMatchmakingTriggerType が "gs2_realtime" であれば必須 |
| completeMatchmakingTriggerScriptId | string | {completeMatchmakingTriggerType} == "gs2_script" | ✓※|  |  ~ 1024文字 | マッチメイキング完了時に実行される GS2-Script のスクリプトGRN<br>Script トリガーリファレンス - [`completeMatchmaking`](../script/#completematchmaking)<br>※ completeMatchmakingTriggerType が "gs2_script" であれば必須 |
| enableCollaborateSeasonRating | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"enable",<br>&nbsp;&nbsp;"disable"<br>}<br> |  | | "disable" |  | シーズンレーティング連携の有効化<br>シーズンベースのレーティング計算のために GS2-SeasonRating との連携を有効にするかどうか。<br>有効にすると、マッチメイキング完了時に指定した GS2-SeasonRating のネームスペースにレーティング計算セッションが自動作成されます。<br>デフォルトは "disable" です。"enable": 有効 / "disable": 無効 /  |
| collaborateSeasonRatingNamespaceId | string | {enableCollaborateSeasonRating} == "enable" | ✓※|  |  ~ 1024文字 | シーズンレーティングネームスペースGRN<br>マッチメイキング完了時にレーティング計算セッションが作成される GS2-SeasonRating のネームスペースの GRN。<br>シーズンレーティング連携が有効な場合のみ適用されます。<br>※ enableCollaborateSeasonRating が "enable" であれば必須 |
| collaborateSeasonRatingTtl | int | {enableCollaborateSeasonRating} == "enable" | | 60 | 60 ~ 7200 | シーズンレーティング結果TTL（秒）<br>マッチメイキング完了後、GS2-SeasonRating 経由の対戦結果送信を受け付ける最大待機時間（秒）。<br>この期間内に結果が送信されない場合、レーティングセッションは期限切れとなります。60 から 7200 秒の範囲で指定します。デフォルトは 60 です。<br>※ enableCollaborateSeasonRating が "enable" であれば必須 |
| changeRatingScript | [ScriptSetting](#scriptsetting) |  | |  |  | レーティング値が変化したときに実行するスクリプトの設定<br>Script トリガーリファレンス - [`changeRating`](../script/#changerating) |
| joinNotification | [NotificationSetting](#notificationsetting) |  | |  |  | 参加通知<br>新しいプレイヤーがギャザリングに参加したときのプッシュ通知設定。<br>既存の参加者に新しいプレイヤーが参加したことを通知し、ゲームクライアントがマッチメイキング UI を更新できるようにします。 |
| leaveNotification | [NotificationSetting](#notificationsetting) |  | |  |  | 離脱通知<br>プレイヤーがギャザリングから離脱したときのプッシュ通知設定。<br>残りの参加者にプレイヤーが離脱したことを通知し、ゲームクライアントに変更を反映させます。 |
| completeNotification | [NotificationSetting](#notificationsetting) |  | |  |  | 完了通知<br>マッチメイキングが完了した（すべてのロール枠が埋まった）ときのプッシュ通知設定。<br>すべての参加者にギャザリングが満員になり対戦を開始できることを通知します。 |
| changeRatingNotification | [NotificationSetting](#notificationsetting) |  | |  |  | レーティング変動通知<br>投票処理後にプレイヤーのレーティング値が変動したときのプッシュ通知設定。<br>影響を受けたプレイヤーに新しいレーティングを通知し、ゲームクライアントに更新された値を表示させます。 |
| logSetting | [LogSetting](#logsetting) |  | |  |  | ログの出力設定<br>APIリクエスト・レスポンスのログを GS2-Log に出力するための設定。<br>設定すると、マッチメイキングの操作（ギャザリングの作成・参加・離脱、投票、レーティング変動など）がモニタリングと分析のためにログ出力されます。 |

#### GetAttr

[!GetAttr](/articles/tech/deploy/#getattr)タグで取得可能なリソースの生成結果

| | 型 | 説明 |
| --- | --- | --- |
| Item | [Namespace](../sdk#namespace) | 作成したネームスペース

#### 実装例




**GS2-Deploy(YAML)**
```yaml

Type: GS2::Matchmaking::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  EnableRating: true
  EnableDisconnectDetection: null
  DisconnectDetectionTimeoutSeconds: null
  CreateGatheringTriggerType: none
  CreateGatheringTriggerRealtimeNamespaceId: null
  CreateGatheringTriggerScriptId: null
  CompleteMatchmakingTriggerType: none
  CompleteMatchmakingTriggerRealtimeNamespaceId: null
  CompleteMatchmakingTriggerScriptId: null
  EnableCollaborateSeasonRating: disable
  CollaborateSeasonRatingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:seasonRating:namespace-0001
  CollaborateSeasonRatingTtl: 60
  ChangeRatingScript: null
  JoinNotification: null
  LeaveNotification: null
  CompleteNotification: null
  ChangeRatingNotification: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001

```

**Go**
```go

import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/matchmaking"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
matchmaking.NewNamespace(
    &SampleStack,
    "namespace-0001",
    matchmaking.NamespaceOptions{
        EnableRating: true,
        CreateGatheringTriggerType: matchmaking.NamespaceCreateGatheringTriggerTypeNone,
        CompleteMatchmakingTriggerType: matchmaking.NamespaceCompleteMatchmakingTriggerTypeNone,
        EnableCollaborateSeasonRating: matchmaking.NamespaceEnableCollaborateSeasonRatingDisable,
        CollaborateSeasonRatingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:seasonRating:namespace-0001"),
        CollaborateSeasonRatingTtl: pointy.Int32(60),
        LogSetting: &core.LogSetting{
            LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
        },
    },
)

println(SampleStack.Yaml())  // Generate Template

```

**PHP**
```php

class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        new \Gs2Cdk\Matchmaking\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            options: new \Gs2Cdk\Matchmaking\Model\Options\NamespaceOptions(
                enableRating: true,
                createGatheringTriggerType: \Gs2Cdk\Matchmaking\Model\Enums\NamespaceCreateGatheringTriggerType::NONE,
                completeMatchmakingTriggerType: \Gs2Cdk\Matchmaking\Model\Enums\NamespaceCompleteMatchmakingTriggerType::NONE,
                enableCollaborateSeasonRating: \Gs2Cdk\Matchmaking\Model\Enums\NamespaceEnableCollaborateSeasonRating::DISABLE,
                collaborateSeasonRatingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:seasonRating:namespace-0001",
                collaborateSeasonRatingTtl: 60,
                logSetting: new \Gs2Cdk\Core\Model\LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            )
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template

```

**Java**
```java

class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.matchmaking.model.Namespace(
                this,
                "namespace-0001",
                new io.gs2.cdk.matchmaking.model.options.NamespaceOptions()
                        .withEnableRating(true)
                        .withCreateGatheringTriggerType(io.gs2.cdk.matchmaking.model.enums.NamespaceCreateGatheringTriggerType.NONE)
                        .withCompleteMatchmakingTriggerType(io.gs2.cdk.matchmaking.model.enums.NamespaceCompleteMatchmakingTriggerType.NONE)
                        .withEnableCollaborateSeasonRating(io.gs2.cdk.matchmaking.model.enums.NamespaceEnableCollaborateSeasonRating.DISABLE)
                        .withCollaborateSeasonRatingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:seasonRating:namespace-0001")
                        .withCollaborateSeasonRatingTtl(60)
                        .withLogSetting(new io.gs2.cdk.core.model.LogSetting(
                            "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                        ))
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template

```

**C#**
```csharp

public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Matchmaking.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            options: new Gs2Cdk.Gs2Matchmaking.Model.Options.NamespaceOptions
            {
                enableRating = true,
                createGatheringTriggerType = Gs2Cdk.Gs2Matchmaking.Model.Enums.NamespaceCreateGatheringTriggerType.None,
                completeMatchmakingTriggerType = Gs2Cdk.Gs2Matchmaking.Model.Enums.NamespaceCompleteMatchmakingTriggerType.None,
                enableCollaborateSeasonRating = Gs2Cdk.Gs2Matchmaking.Model.Enums.NamespaceEnableCollaborateSeasonRating.Disable,
                collaborateSeasonRatingNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:seasonRating:namespace-0001",
                collaborateSeasonRatingTtl = 60,
                logSetting = new Gs2Cdk.Core.Model.LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

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

```

**TypeScript**
```typescript

import core from "@/gs2cdk/core";
import matchmaking from "@/gs2cdk/matchmaking";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new matchmaking.model.Namespace(
            this,
            "namespace-0001",
            {
                enableRating: true,
                createGatheringTriggerType: matchmaking.model.NamespaceCreateGatheringTriggerType.NONE,
                completeMatchmakingTriggerType: matchmaking.model.NamespaceCompleteMatchmakingTriggerType.NONE,
                enableCollaborateSeasonRating: matchmaking.model.NamespaceEnableCollaborateSeasonRating.DISABLE,
                collaborateSeasonRatingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:seasonRating:namespace-0001",
                collaborateSeasonRatingTtl: 60,
                logSetting: new core.LogSetting(
                    "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template

```

**Python**
```python

from gs2_cdk import Stack, core, matchmaking

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        matchmaking.Namespace(
            stack=self,
            name='namespace-0001',
            options=matchmaking.NamespaceOptions(
                enable_rating=True,
                create_gathering_trigger_type=matchmaking.NamespaceCreateGatheringTriggerType.NONE,
                complete_matchmaking_trigger_type=matchmaking.NamespaceCompleteMatchmakingTriggerType.NONE,
                enable_collaborate_season_rating=matchmaking.NamespaceEnableCollaborateSeasonRating.DISABLE,
                collaborate_season_rating_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:seasonRating:namespace-0001',
                collaborate_season_rating_ttl=60,
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        )

print(SampleStack().yaml())  # Generate Template

```


#### TransactionSetting

トランザクション設定<br>

トランザクション設定は、トランザクションの実行方法・整合性・非同期処理・競合回避の仕組みを制御する設定です。<br>
自動実行（AutoRun）、アトミック実行（AtomicCommit）、GS2-Distributor を利用した非同期実行、スクリプト結果の一括適用、GS2-JobQueue による入手アクションの非同期化などを組み合わせ、ゲームロジックに応じた堅牢なトランザクション管理を可能にします。

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| enableAutoRun | bool |  |  | false |  | 発行したトランザクションをサーバーサイドで自動的に実行するか |
| enableAtomicCommit | bool | {enableAutoRun} == true |  | false |  | トランザクションの実行をアトミックにコミットするか<br>※ enableAutoRun が true であれば 有効 |
| transactionUseDistributor | bool | {enableAtomicCommit} == true |  | false |  | トランザクションを非同期処理で実行する<br>※ enableAtomicCommit が true であれば 有効 |
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true |  | false |  | スクリプトの結果コミット処理を非同期処理で実行するか<br>※ transactionUseDistributor が true であれば 有効 |
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true |  | false |  | 入手アクションを実行する際に GS2-JobQueue を使用するか<br>※ 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 |

#### ScriptSetting

スクリプト設定<br>

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

スクリプトの実行方式は大きく2種類あり、それは「同期実行」と「非同期実行」です。<br>
同期実行は、スクリプトの実行が完了するまで処理がブロックされます。<br>
代わりに、スクリプトの実行結果を使って API の実行を止めたり、API のレスポンス内容を制御することができます。<br>

一方、非同期実行ではスクリプトの完了を待つために処理がブロックされることはありません。<br>
ただし、スクリプトの実行結果を利用して API の実行を停止したり、API の応答内容を変更することはできません。<br>
非同期実行は API の応答フローに影響を与えないため、原則として非同期実行を推奨します。<br>

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

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| triggerScriptId | string |  |  |  |  ~ 1024文字 | API 実行時に同期的に実行される GS2-Script のスクリプトGRN<br>「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。 |
| doneTriggerTargetType | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"none",<br>&nbsp;&nbsp;"gs2_script",<br>&nbsp;&nbsp;"aws"<br>}<br> |  |  | "none" |  | 非同期スクリプトの実行方法<br>非同期実行で使用するスクリプトの種類を指定します。<br>「非同期実行のスクリプトを使用しない(none)」「GS2-Scriptを使用する(gs2_script)」「Amazon EventBridgeを使用する(aws)」が選択できます。"none": なし / "gs2_script": GS2-Script / "aws": Amazon EventBridge /  |
| doneTriggerScriptId | string | {doneTriggerTargetType} == "gs2_script" |  |  |  ~ 1024文字 | 非同期実行する GS2-Script スクリプトGRN<br>「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。<br>※ doneTriggerTargetType が "gs2_script" であれば 有効 |
| doneTriggerQueueNamespaceId | string | {doneTriggerTargetType} == "gs2_script" |  |  |  ~ 1024文字 | 非同期実行スクリプトを実行する GS2-JobQueue ネームスペースGRN<br>非同期実行スクリプトを直接実行するのではなく、GS2-JobQueue を経由する場合は GS2-JobQueue のネームスペースGRN を指定します。<br>GS2-JobQueue を利用する理由は多くはありませんので、特に理由がなければ指定する必要はありません。<br>※ doneTriggerTargetType が "gs2_script" であれば 有効 |

#### NotificationSetting

プッシュ通知に関する設定<br>

GS2 のマイクロサービス内で何らかのイベントが発生した際に、プッシュ通知を送信するための設定です。<br>
ここでいうプッシュ通知は GS2-Gateway の提供する WebSocket インターフェースを経由した処理であり、スマートフォンのプッシュ通知とは性質が異なります。<br>
たとえば、マッチメイキングが完了した時やフレンドリクエストが届いた時など、ゲームクライアントの操作とは関係なく状態が変化した際に GS2-Gateway を経由してプッシュ通知をすることで、ゲームクライアントは状態の変化を検知することができます。<br>

GS2-Gateway のプッシュ通知は通知先のデバイスがオフラインだった時に追加の処理としてモバイルプッシュ通知を送信できます。<br>
モバイルプッシュ通知をうまく利用すれば、マッチメイキング中にゲームを終了しても、モバイルプッシュ通知を使用してプレイヤーに通知し、ゲームに戻ってくるフローを実現できる可能性があります。

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| gatewayNamespaceId | string |  |  | "grn:gs2:{region}:{ownerId}:gateway:default" |  ~ 1024文字 | プッシュ通知に使用する GS2-Gateway のネームスペース<br>「grn:gs2:」から始まる GRN 形式で GS2-Gateway のネームスペースIDを指定します。 |
| enableTransferMobileNotification | bool? |  |  | false |  | モバイルプッシュ通知へ転送するか<br>この通知を送信しようとした時、通知先のデバイスがオフラインだった場合、モバイルプッシュ通知へ転送するかどうかを指定します。 |
| sound | string | {enableTransferMobileNotification} == true |  |  |  ~ 1024文字 | モバイルプッシュ通知で使用するサウンドファイル名<br>ここで指定したサウンドファイル名は、モバイルプッシュ通知を送信する際に使用され、特別なサウンドで通知を出すことができます。<br>※ enableTransferMobileNotification が true であれば 有効 |
| enable | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"Enabled",<br>&nbsp;&nbsp;"Disabled"<br>}<br> |  |  | "Enabled" |  | プッシュ通知を有効にするか"Enabled": 有効 / "Disabled": 無効 /  |

#### LogSetting

ログの出力設定<br>

ログデータの出力設定を管理します。この型は、ログデータを書き出すために使用される GS2-Log ネームスペースの識別子（Namespace ID）を保持します。<br>
ログネームスペースID(loggingNamespaceId)には、ログデータを収集し保存する GS2-Log のネームスペースを、GRNの形式で指定します。<br>
この設定をすることで、設定されたネームスペース内で発生したAPIリクエスト・レスポンスのログデータが、対象の GS2-Log ネームスペース側へ出力されるようになります。<br>
GS2-Log ではリアルタイムでログが提供され、システムの監視や分析、デバッグなどに利用できます。

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| loggingNamespaceId | string |  | ✓ |  |  ~ 1024文字 | ログを出力する GS2-Log のネームスペースGRN<br>「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。 |

---

### CurrentModelMaster

現在アクティブなモデルのマスターデータ<br>

現在ネームスペース内で有効な、モデルの定義を記述したマスターデータです。<br>
GS2ではマスターデータの管理にJSON形式のファイルを使用します。<br>
ファイルをアップロードすることで、実際にサーバーに設定を反映することができます。<br>

JSONファイルを作成する方法として、マネージメントコンソール内にマスターデータエディタを提供しています。<br>
また、よりゲームの運営に相応しいツールを作成し、適切なフォーマットのJSONファイルを書き出すことでもサービスを利用可能です。
{{% alert title="Note" color="info" %}}
JSONファイルの形式については [GS2-Matchmaking マスターデータリファレンス](api_reference/matchmaking/master_data/) をご参照ください。
{{% /alert %}}

#### Request

リソースの生成・更新リクエスト

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| mode | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"direct",<br>&nbsp;&nbsp;"preUpload"<br>}<br> |  | | "direct" |  | 更新モード"direct": マスターデータを直接更新 / "preUpload": マスターデータをアップロードしてから更新 /  |
| settings | string | {mode} == "direct" | ✓※|  |  ~ 5242880 バイト (5MB) | マスターデータ<br>※ mode が "direct" であれば必須 |
| uploadToken | string | {mode} == "preUpload" | ✓※|  |  ~ 1024文字 | 事前アップロードで取得したトークン<br>アップロードしたマスターデータを適用するために使用されます。<br>※ mode が "preUpload" であれば必須 |

#### GetAttr

[!GetAttr](/articles/tech/deploy/#getattr)タグで取得可能なリソースの生成結果

| | 型 | 説明 |
| --- | --- | --- |
| Item | [CurrentModelMaster](../sdk#currentmodelmaster) | 更新された現在アクティブなモデルのマスターデータ

#### 実装例




**GS2-Deploy(YAML)**
```yaml

Type: GS2::Matchmaking::CurrentModelMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2020-06-24",
    "ratingModels": [
      {
        "name": "rating-0001",
        "initialValue": 1500,
        "volatility": 100,
        "metadata": "RATING_0001"
      },
      {
        "name": "rating-0002",
        "initialValue": 1500,
        "volatility": 150,
        "metadata": "RATING_0002"
      }
    ],
    "seasonModels": [
      {
        "name": "season-0001",
        "maximumParticipants": 50,
        "challengePeriodEventId": "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
      },
      {
        "name": "season-0002",
        "maximumParticipants": 100,
        "challengePeriodEventId": "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
      }
    ]
  }
  UploadToken: null

```

**Go**
```go

import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/matchmaking"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
matchmaking.NewNamespace(
    &SampleStack,
    "namespace-0001",
    matchmaking.NamespaceOptions{},
).MasterData(
    []matchmaking.RatingModel{
        matchmaking.NewRatingModel(
            "rating-0001",
            1500,
            100,
            matchmaking.RatingModelOptions{
                Metadata: pointy.String("RATING_0001"),
            },
        ),
        matchmaking.NewRatingModel(
            "rating-0002",
            1500,
            150,
            matchmaking.RatingModelOptions{
                Metadata: pointy.String("RATING_0002"),
            },
        ),
    },
    []matchmaking.SeasonModel{
        matchmaking.NewSeasonModel(
            "season-0001",
            50,
            "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001",
            matchmaking.SeasonModelOptions{
            },
        ),
        matchmaking.NewSeasonModel(
            "season-0002",
            100,
            "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002",
            matchmaking.SeasonModelOptions{
            },
        ),
    },
)

println(SampleStack.Yaml())  // Generate Template

```

**PHP**
```php

class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Matchmaking\Model\Namespace_(
            stack: $this,
            name: "namespace-0001"
        ))->masterData(
            [
                new \Gs2Cdk\Matchmaking\Model\RatingModel(
                    name:"rating-0001",
                    initialValue:1500,
                    volatility:100,
                    options: new \Gs2Cdk\Matchmaking\Model\Options\RatingModelOptions(
                        metadata:"RATING_0001"
                    )
                ),
                new \Gs2Cdk\Matchmaking\Model\RatingModel(
                    name:"rating-0002",
                    initialValue:1500,
                    volatility:150,
                    options: new \Gs2Cdk\Matchmaking\Model\Options\RatingModelOptions(
                        metadata:"RATING_0002"
                    )
                )
            ],
            [
                new \Gs2Cdk\Matchmaking\Model\SeasonModel(
                    name:"season-0001",
                    maximumParticipants:50,
                    challengePeriodEventId:"grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
                ),
                new \Gs2Cdk\Matchmaking\Model\SeasonModel(
                    name:"season-0002",
                    maximumParticipants:100,
                    challengePeriodEventId:"grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template

```

**Java**
```java

class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.matchmaking.model.Namespace(
            this,
            "namespace-0001"
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.matchmaking.model.RatingModel(
                    "rating-0001",
                    1500,
                    100,
                    new io.gs2.cdk.matchmaking.model.options.RatingModelOptions()
                        .withMetadata("RATING_0001")
                ),
                new io.gs2.cdk.matchmaking.model.RatingModel(
                    "rating-0002",
                    1500,
                    150,
                    new io.gs2.cdk.matchmaking.model.options.RatingModelOptions()
                        .withMetadata("RATING_0002")
                )
            ),
            Arrays.asList(
                new io.gs2.cdk.matchmaking.model.SeasonModel(
                    "season-0001",
                    50,
                    "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
                ),
                new io.gs2.cdk.matchmaking.model.SeasonModel(
                    "season-0002",
                    100,
                    "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template

```

**C#**
```csharp

public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Matchmaking.Model.Namespace(
            stack: this,
            name: "namespace-0001"
        ).MasterData(
            new Gs2Cdk.Gs2Matchmaking.Model.RatingModel[] {
                new Gs2Cdk.Gs2Matchmaking.Model.RatingModel(
                    name: "rating-0001",
                    initialValue: 1500,
                    volatility: 100,
                    options: new Gs2Cdk.Gs2Matchmaking.Model.Options.RatingModelOptions
                    {
                        metadata = "RATING_0001"
                    }
                ),
                new Gs2Cdk.Gs2Matchmaking.Model.RatingModel(
                    name: "rating-0002",
                    initialValue: 1500,
                    volatility: 150,
                    options: new Gs2Cdk.Gs2Matchmaking.Model.Options.RatingModelOptions
                    {
                        metadata = "RATING_0002"
                    }
                )
            },
            new Gs2Cdk.Gs2Matchmaking.Model.SeasonModel[] {
                new Gs2Cdk.Gs2Matchmaking.Model.SeasonModel(
                    name: "season-0001",
                    maximumParticipants: 50,
                    challengePeriodEventId: "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
                ),
                new Gs2Cdk.Gs2Matchmaking.Model.SeasonModel(
                    name: "season-0002",
                    maximumParticipants: 100,
                    challengePeriodEventId: "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
                )
            }
        );
    }
}

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

```

**TypeScript**
```typescript

import core from "@/gs2cdk/core";
import matchmaking from "@/gs2cdk/matchmaking";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new matchmaking.model.Namespace(
            this,
            "namespace-0001",
        ).masterData(
            [
                new matchmaking.model.RatingModel(
                    "rating-0001",
                    1500,
                    100,
                    {
                        metadata: "RATING_0001"
                    }
                ),
                new matchmaking.model.RatingModel(
                    "rating-0002",
                    1500,
                    150,
                    {
                        metadata: "RATING_0002"
                    }
                )
            ],
            [
                new matchmaking.model.SeasonModel(
                    "season-0001",
                    50,
                    "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
                ),
                new matchmaking.model.SeasonModel(
                    "season-0002",
                    100,
                    "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
                )
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template

```

**Python**
```python

from gs2_cdk import Stack, core, matchmaking

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        matchmaking.Namespace(
            stack=self,
            name="namespace-0001",
            options=matchmaking.NamespaceOptions(
                enable_rating=True,
                enable_collaborate_season_rating=matchmaking.NamespaceEnableCollaborateSeasonRating.DISABLE,
                collaborate_season_rating_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:seasonRating:namespace-0001',
                collaborate_season_rating_ttl=60,
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        ).master_data(
            rating_models=[
                matchmaking.RatingModel(
                    name='rating-0001',
                    initial_value=1500,
                    volatility=100,
                    options=matchmaking.RatingModelOptions(
                        metadata = 'RATING_0001'
                    ),
                ),
                matchmaking.RatingModel(
                    name='rating-0002',
                    initial_value=1500,
                    volatility=150,
                    options=matchmaking.RatingModelOptions(
                        metadata = 'RATING_0002'
                    ),
                ),
            ],
            season_models=[
                matchmaking.SeasonModel(
                    name='season-0001',
                    maximum_participants=50,
                    challenge_period_event_id='grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001'
                ),
                matchmaking.SeasonModel(
                    name='season-0002',
                    maximum_participants=100,
                    challenge_period_event_id='grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002'
                ),
            ],
        )

print(SampleStack().yaml())  # Generate Template

```


#### RatingModel

レーティングモデル<br>

GS2 ではレーティングアルゴリズムとして Glicko-2 を採用しています。<br>
Glicko-2 には複数のパラメータがありますが、GS2-Matchmaking ではそれらを総合的に表す ボラティリティ という1つのパラメータに集約しています。<br>
ボラティリティ は変化の大きさを表すパラメータで、値が大きいほどレーティングの値の変動量が大きくなります。

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| ratingModelId | string |  | ※ |  |  ~ 1024文字 | レーティングモデルGRN<br>※ サーバーが自動で設定 |
| name | string |  | ✓ |  |  ~ 128文字 | レーティングモデル名<br>レーティングモデル固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| metadata | string |  |  |  |  ~ 128文字 | メタデータ<br>メタデータには任意の値を設定できます。<br>これらの値は GS2 の動作には影響しないため、ゲーム内で利用する情報の保存先として使用できます。 |
| initialValue | int |  |  | 1500 | 100 ~ 10000 | レート値の初期値<br>プレイヤーが初めてレーティング付きマッチメイキングに参加したときに割り当てられる開始レート値。<br>デフォルトは 1500 です。すべてのプレイヤーは同じレーティングから開始し、対戦結果に基づいて調整されます。 |
| volatility | int |  |  | 100 | 1 ~ 20000 | レーティングのボラティリティ<br>各対戦後にレート値がどの程度変動するかを制御する Glicko-2 のパラメータ。<br>値が大きいほどレーティングの変動幅が大きくなり、より早くレーティングが調整されます。<br>値が小さいほどレーティングが安定し、緩やかに変化します。デフォルトは 100 です。 |

#### SeasonModel

シーズンモデル<br>

シーズンマッチメイキングにおいて、一定期間有効な永続ギャザリングの期間・最大参加人数・ティアー連携設定を定義するマスターデータです。<br>
GS2-Schedule により期間を管理し、必要に応じて GS2-Experience と連携して同一ティアー内で永続ギャザリングを形成します。

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| seasonModelId | string |  | ※ |  |  ~ 1024文字 | シーズンモデルGRN<br>※ サーバーが自動で設定 |
| name | string |  | ✓ |  |  ~ 128文字 | シーズンモデル名<br>シーズンモデル固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| metadata | string |  |  |  |  ~ 128文字 | メタデータ<br>メタデータには任意の値を設定できます。<br>これらの値は GS2 の動作には影響しないため、ゲーム内で利用する情報の保存先として使用できます。 |
| maximumParticipants | int |  | ✓ |  | 2 ~ 1000 | 最大参加人数<br>1つのシーズンギャザリングに参加可能なプレイヤーの最大人数。<br>この上限に達するとシーズンギャザリングは満員となり、それ以上のプレイヤーは参加できなくなります。<br>2 から 1000 の範囲で指定します。 |
| experienceModelId | string |  |  |  |  ~ 1024文字 | ティアー管理用の経験値モデルGRN<br>プレイヤーのティアーを決定するために使用する GS2-Experience の経験値モデルの GRN。<br>この経験値モデルにおけるプレイヤーのランクがマッチメイキングのティアーとして使用され、同程度のレベルのプレイヤー同士がグルーピングされます。<br>未指定の場合、ティアーによるグルーピングは無効となり、レベルに関係なく全プレイヤーがマッチングされます。 |
| challengePeriodEventId | string |  | ✓ |  |  ~ 1024文字 | チャレンジ期間イベントGRN<br>このシーズンの有効期間を定義する GS2-Schedule イベントの GRN。<br>このイベントがアクティブな間のみ、シーズンギャザリングの作成・参加が可能です。<br>イベント期間が終了するとシーズンがクローズし、新しいマッチメイキングはできなくなります。 |

---



