Documentation index for AI agents

GS2-Buff Deploy/CDK 레퍼런스

GS2-Deploy의 스택을 생성할 때 사용하는 템플릿 포맷과, CDK를 이용한 각종 언어의 템플릿 출력 구현 예제

엔티티

Deploy 처리에서 조작 대상이 되는 리소스

Namespace

네임스페이스

네임스페이스는 하나의 프로젝트 내에서 동일한 서비스를 서로 다른 용도로 여러 개 이용하기 위한 엔티티입니다.
GS2의 각 서비스는 네임스페이스 단위로 관리됩니다. 네임스페이스가 다르면 동일한 서비스라도 완전히 독립된 데이터 공간으로 취급됩니다.

따라서 각 서비스의 이용을 시작하려면 먼저 네임스페이스를 생성해야 합니다.

Request

리소스 생성·갱신 요청

타입활성화 조건필수기본값값 제한설명
namestring
~ 128자네임스페이스 이름
네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
descriptionstring~ 1024자설명문
transactionSettingTransactionSetting트랜잭션 설정
버프 적용 결과에 기반하여 실행되는 분산 트랜잭션의 실행 방법을 제어하는 설정입니다. 자동 실행, 원자적 커밋, 비동기 처리 등의 옵션이 포함됩니다.
applyBuffScriptScriptSetting버프를 적용할 때 실행할 스크립트 설정
Script 트리거 레퍼런스 - apply
logSettingLogSetting로그 출력 설정
버프 조작 로그 데이터를 GS2-Log에 출력하기 위한 설정입니다. API 요청·응답 로그를 수집하는 GS2-Log의 네임스페이스를 지정합니다.

GetAttr

!GetAttr 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemNamespace생성한 네임스페이스

구현 예제

Type: GS2::Buff::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  ApplyBuffScript: null
  LogSetting:
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/buff"
)


SampleStack := core.NewStack()
buff.NewNamespace(
    &SampleStack,
    "namespace-0001",
    buff.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\Buff\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            options: new \Gs2Cdk\Buff\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.buff.model.Namespace(
                this,
                "namespace-0001",
                new io.gs2.cdk.buff.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 Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Buff.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            options: new Gs2Cdk.Gs2Buff.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 Template
import core from "@/gs2cdk/core";
import buff from "@/gs2cdk/buff";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new buff.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, buff

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        buff.Namespace(
            stack=self,
            name='namespace-0001',
            options=buff.NamespaceOptions(
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        )

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

TransactionSetting

트랜잭션 설정

트랜잭션 설정은 트랜잭션의 실행 방법·정합성·비동기 처리·충돌 회피 메커니즘을 제어하는 설정입니다.
자동 실행(AutoRun), 원자적 실행(AtomicCommit), GS2-Distributor를 이용한 비동기 실행, 스크립트 결과의 일괄 적용, GS2-JobQueue를 통한 입수 액션의 비동기화 등을 조합하여 게임 로직에 맞는 견고한 트랜잭션 관리를 가능하게 합니다.

타입활성화 조건필수기본값값 제한설명
enableAutoRunboolfalse발행한 트랜잭션을 서버 사이드에서 자동으로 실행할지 여부
enableAtomicCommitbool{enableAutoRun} == truefalse트랜잭션의 실행을 원자적으로 커밋할지 여부
※ enableAutoRun이(가) true 이면 활성화
transactionUseDistributorbool{enableAtomicCommit} == truefalse트랜잭션을 비동기 처리로 실행할지 여부
※ enableAtomicCommit이(가) true 이면 활성화
commitScriptResultInUseDistributorbool{transactionUseDistributor} == truefalse스크립트의 결과 커밋 처리를 비동기 처리로 실행할지 여부
※ transactionUseDistributor이(가) true 이면 활성화
acquireActionUseJobQueuebool{enableAtomicCommit} == truefalse입수 액션을 실행할 때 GS2-JobQueue를 사용할지 여부
※ enableAtomicCommit이(가) true 이면 활성화
distributorNamespaceIdstring“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024자트랜잭션 실행에 사용하는 GS2-Distributor 네임스페이스 GRN
queueNamespaceIdstring“grn:gs2:{region}:{ownerId}:queue:default”~ 1024자트랜잭션 실행에 사용하는 GS2-JobQueue의 네임스페이스 GRN

ScriptSetting

스크립트 설정

GS2에서는 마이크로서비스의 이벤트에 연결하여 커스텀 스크립트를 실행할 수 있습니다.
이 모델은 스크립트 실행을 트리거하기 위한 설정을 보유합니다.

스크립트 실행 방식은 크게 두 가지로, 바로 “동기 실행"과 “비동기 실행"입니다.
동기 실행은 스크립트 실행이 완료될 때까지 처리가 블록됩니다.
대신 스크립트 실행 결과를 이용하여 API 실행을 중단시키거나 API 응답 내용을 제어할 수 있습니다.

한편, 비동기 실행에서는 스크립트 완료를 기다리기 위해 처리가 블록되는 일이 없습니다.
다만 스크립트 실행 결과를 이용하여 API 실행을 중단하거나 API 응답 내용을 변경할 수는 없습니다.
비동기 실행은 API의 응답 흐름에 영향을 주지 않으므로 원칙적으로 비동기 실행을 권장합니다.

비동기 실행에는 실행 방식이 두 가지 있으며, GS2-Script와 Amazon EventBridge가 있습니다.
Amazon EventBridge를 사용함으로써 Lua 이외의 언어로 처리를 작성할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
triggerScriptIdstring~ 1024자API 실행 시 동기적으로 실행되는 GS2-Script의 스크립트 GRN
“grn:gs2:“로 시작하는 GRN 형식의 ID로 지정해야 합니다.
doneTriggerTargetType문자열 열거형
enum {
  “none”,
  “gs2_script”,
  “aws”
}
“none”비동기 스크립트의 실행 방법
비동기 실행에서 사용할 스크립트의 종류를 지정합니다.
“비동기 실행의 스크립트를 사용하지 않음(none)”, “GS2-Script를 사용함(gs2_script)”, “Amazon EventBridge를 사용함(aws)” 중에서 선택할 수 있습니다.
정의설명
none없음
gs2_scriptGS2-Script
awsAmazon EventBridge
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024자비동기 실행할 GS2-Script 스크립트 GRN
“grn:gs2:“로 시작하는 GRN 형식의 ID로 지정해야 합니다.
※ doneTriggerTargetType이(가) “gs2_script” 이면 활성화
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024자비동기 실행 스크립트를 실행하는 GS2-JobQueue 네임스페이스 GRN
비동기 실행 스크립트를 직접 실행하지 않고 GS2-JobQueue를 경유하는 경우 GS2-JobQueue의 네임스페이스GRN을 지정합니다.
GS2-JobQueue를 이용해야 할 이유는 많지 않으므로, 특별한 이유가 없다면 지정할 필요는 없습니다.
※ doneTriggerTargetType이(가) “gs2_script” 이면 활성화

LogSetting

로그 출력 설정

로그 데이터의 출력 설정을 관리합니다. 이 타입은 로그 데이터를 기록하는 데 사용되는 GS2-Log 네임스페이스의 식별자(Namespace ID)를 보유합니다.
로그 네임스페이스ID(loggingNamespaceId)에는 로그 데이터를 수집하여 저장하는 GS2-Log의 네임스페이스를 GRN 형식으로 지정합니다.
이 설정을 하면 설정된 네임스페이스 내에서 발생한 API 요청·응답의 로그 데이터가 대상 GS2-Log 네임스페이스 쪽으로 출력됩니다.
GS2-Log에서는 실시간으로 로그가 제공되어 시스템 모니터링, 분석, 디버깅 등에 이용할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
loggingNamespaceIdstring
~ 1024자로그를 출력할 GS2-Log의 네임스페이스 GRN
“grn:gs2:“로 시작하는 GRN 형식의 ID로 지정해야 합니다.

CurrentBuffMaster

현재 활성화된 버프 엔트리 모델의 마스터 데이터

현재 네임스페이스 내에서 유효한 버프 엔트리 모델의 정의를 기술한 마스터 데이터입니다.
GS2에서는 마스터 데이터 관리에 JSON 형식의 파일을 사용합니다.
파일을 업로드함으로써 실제로 서버에 설정을 반영할 수 있습니다.

JSON 파일을 작성하는 방법으로, 매니지먼트 콘솔 내에 마스터 데이터 에디터를 제공하고 있습니다.
또한 게임 운영에 더 적합한 도구를 직접 제작하여, 적절한 형식의 JSON 파일을 출력하는 방식으로도 서비스를 이용할 수 있습니다.

Request

리소스 생성·갱신 요청

타입활성화 조건필수기본값값 제한설명
namespaceNamestring
~ 128자네임스페이스 이름
네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
mode문자열 열거형
enum {
  “direct”,
  “preUpload”
}
“direct”업데이트 모드
정의설명
direct마스터 데이터를 직접 업데이트
preUpload마스터 데이터를 업로드한 후 업데이트
settingsstring{mode} == “direct”
✓※
~ 5242880 바이트 (5MB)마스터 데이터
※ mode이(가) “direct” 이면 필수
uploadTokenstring{mode} == “preUpload”
✓※
~ 1024자사전 업로드로 획득한 토큰
업로드한 마스터 데이터를 적용하기 위해 사용됩니다.
※ mode이(가) “preUpload” 이면 필수

GetAttr

!GetAttr 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemCurrentBuffMaster갱신된 현재 활성화된 버프 엔트리 모델의 마스터 데이터

구현 예제

Type: GS2::Buff::CurrentBuffMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2024-04-15",
    "buffEntryModels": [
      {
        "name": "buff-0001",
        "expression": "rate_add",
        "targetType": "model",
        "priority": 1,
        "metadata": "BUFF_0001",
        "targetModel":
          {
            "targetModelName": "Gs2Experience:Status",
            "targetFieldName": "rankCapValue",
            "conditionGrns": [
              {
                "targetModelName": "Gs2Experience:ExperienceModel",
                "targetGrn": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
              },
              {
                "targetModelName": "Gs2Experience:ExperienceModel",
                "targetGrn": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002"
              }
            ],
            "rate": 1.0
          }
      },
      {
        "name": "buff-0002",
        "expression": "mul",
        "targetType": "action",
        "priority": 2,
        "metadata": "BUFF_0002",
        "targetAction":
          {
            "targetActionName": "Gs2Experience:AddExperienceByUserId",
            "targetFieldName": "experienceValue",
            "conditionGrns": [
              {
                "targetModelName": "Gs2Experience:ExperienceModel",
                "targetGrn": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
              }
            ],
            "rate": 2.0
          }
      },
      {
        "name": "buff-0003",
        "expression": "mul",
        "targetType": "model",
        "priority": 3,
        "metadata": "BUFF_0003",
        "targetModel":
          {
            "targetModelName": "Gs2Experience:Status",
            "targetFieldName": "rankCapValue",
            "conditionGrns": [
              {
                "targetModelName": "Gs2Experience:ExperienceModel",
                "targetGrn": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
              }
            ],
            "rate": 3.0
          }
      }
    ]
  }
  UploadToken: null
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/buff"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
buff.NewNamespace(
    &SampleStack,
    "namespace-0001",
    buff.NamespaceOptions{},
).MasterData(
    []buff.BuffEntryModel{
        buff.NewBuffEntryModel(
            "buff-0001",
            buff.BuffEntryModelExpressionRateAdd,
            buff.BuffEntryModelTargetTypeModel,
            1,
            buff.BuffEntryModelOptions{
                Metadata: pointy.String("BUFF_0001"),
                TargetModel: &buff.BuffTargetModel{
                    TargetModelName: buff.BuffTargetModelTargetModelNameGs2ExperienceStatus,
                    TargetFieldName: "rankCapValue",
                    ConditionGrns: []buff.BuffTargetGrn{
                        buff.NewBuffTargetGrn(
                            "Gs2Experience:ExperienceModel",
                            "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                            buff.BuffTargetGrnOptions{},
                        ),
                        buff.NewBuffTargetGrn(
                            "Gs2Experience:ExperienceModel",
                            "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002",
                            buff.BuffTargetGrnOptions{},
                        ),
                    },
                    Rate: 1.0,
                },
            },
        ),
        buff.NewBuffEntryModel(
            "buff-0002",
            buff.BuffEntryModelExpressionMul,
            buff.BuffEntryModelTargetTypeAction,
            2,
            buff.BuffEntryModelOptions{
                Metadata: pointy.String("BUFF_0002"),
                TargetAction: &buff.BuffTargetAction{
                    TargetActionName: buff.BuffTargetActionTargetActionNameGs2ExperienceAddExperienceByUserId,
                    TargetFieldName: "experienceValue",
                    ConditionGrns: []buff.BuffTargetGrn{
                        buff.NewBuffTargetGrn(
                            "Gs2Experience:ExperienceModel",
                            "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                            buff.BuffTargetGrnOptions{},
                        ),
                    },
                    Rate: 2.0,
                },
            },
        ),
        buff.NewBuffEntryModel(
            "buff-0003",
            buff.BuffEntryModelExpressionMul,
            buff.BuffEntryModelTargetTypeModel,
            3,
            buff.BuffEntryModelOptions{
                Metadata: pointy.String("BUFF_0003"),
                TargetModel: &buff.BuffTargetModel{
                    TargetModelName: buff.BuffTargetModelTargetModelNameGs2ExperienceStatus,
                    TargetFieldName: "rankCapValue",
                    ConditionGrns: []buff.BuffTargetGrn{
                        buff.NewBuffTargetGrn(
                            "Gs2Experience:ExperienceModel",
                            "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                            buff.BuffTargetGrnOptions{},
                        ),
                    },
                    Rate: 3.0,
                },
            },
        ),
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Buff\Model\Namespace_(
            stack: $this,
            name: "namespace-0001"
        ))->masterData(
            [
                new \Gs2Cdk\Buff\Model\BuffEntryModel(
                    name:"buff-0001",
                    expression: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelExpression::RATE_ADD,
                    targetType: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelTargetType::MODEL,
                    priority:1,
                    options: new \Gs2Cdk\Buff\Model\Options\BuffEntryModelOptions(
                        metadata:"BUFF_0001",
                        targetModel:new \Gs2Cdk\Buff\Model\BuffTargetModel(
                            targetModelName: \Gs2Cdk\Buff\Model\Enums\BuffTargetModelTargetModelName::GS2_EXPERIENCE_STATUS,
                            targetFieldName: "rankCapValue",
                            conditionGrns: [
                                new \Gs2Cdk\Buff\Model\BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                                ),
                                new \Gs2Cdk\Buff\Model\BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002",
                                ),
                            ],
                            rate: 1.0,
                        )
                    )
                ),
                new \Gs2Cdk\Buff\Model\BuffEntryModel(
                    name:"buff-0002",
                    expression: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelExpression::MUL,
                    targetType: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelTargetType::ACTION,
                    priority:2,
                    options: new \Gs2Cdk\Buff\Model\Options\BuffEntryModelOptions(
                        metadata:"BUFF_0002",
                        targetAction:new \Gs2Cdk\Buff\Model\BuffTargetAction(
                            targetActionName: \Gs2Cdk\Buff\Model\Enums\BuffTargetActionTargetActionName::GS2_EXPERIENCE_ADD_EXPERIENCE_BY_USER_ID,
                            targetFieldName: "experienceValue",
                            conditionGrns: [
                                new \Gs2Cdk\Buff\Model\BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                                ),
                            ],
                            rate: 2.0,
                        )
                    )
                ),
                new \Gs2Cdk\Buff\Model\BuffEntryModel(
                    name:"buff-0003",
                    expression: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelExpression::MUL,
                    targetType: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelTargetType::MODEL,
                    priority:3,
                    options: new \Gs2Cdk\Buff\Model\Options\BuffEntryModelOptions(
                        metadata:"BUFF_0003",
                        targetModel:new \Gs2Cdk\Buff\Model\BuffTargetModel(
                            targetModelName: \Gs2Cdk\Buff\Model\Enums\BuffTargetModelTargetModelName::GS2_EXPERIENCE_STATUS,
                            targetFieldName: "rankCapValue",
                            conditionGrns: [
                                new \Gs2Cdk\Buff\Model\BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                                ),
                            ],
                            rate: 3.0,
                        )
                    )
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.buff.model.Namespace(
            this,
            "namespace-0001"
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.buff.model.BuffEntryModel(
                    "buff-0001",
                    io.gs2.cdk.buff.model.enums.BuffEntryModelExpression.RATE_ADD,
                    io.gs2.cdk.buff.model.enums.BuffEntryModelTargetType.MODEL,
                    1,
                    new io.gs2.cdk.buff.model.options.BuffEntryModelOptions()
                        .withMetadata("BUFF_0001")
                        .withTargetModel(new io.gs2.cdk.buff.model.BuffTargetModel(
                            io.gs2.cdk.buff.model.enums.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            "rankCapValue",
                            Arrays.asList(
                                new io.gs2.cdk.buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
                                ),
                                new io.gs2.cdk.buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002"
                                )
                            ),
                            1.0f
                        ))
                ),
                new io.gs2.cdk.buff.model.BuffEntryModel(
                    "buff-0002",
                    io.gs2.cdk.buff.model.enums.BuffEntryModelExpression.MUL,
                    io.gs2.cdk.buff.model.enums.BuffEntryModelTargetType.ACTION,
                    2,
                    new io.gs2.cdk.buff.model.options.BuffEntryModelOptions()
                        .withMetadata("BUFF_0002")
                        .withTargetAction(new io.gs2.cdk.buff.model.BuffTargetAction(
                            io.gs2.cdk.buff.model.enums.BuffTargetActionTargetActionName.GS2_EXPERIENCE_ADD_EXPERIENCE_BY_USER_ID,
                            "experienceValue",
                            Arrays.asList(
                                new io.gs2.cdk.buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
                                )
                            ),
                            2.0f
                        ))
                ),
                new io.gs2.cdk.buff.model.BuffEntryModel(
                    "buff-0003",
                    io.gs2.cdk.buff.model.enums.BuffEntryModelExpression.MUL,
                    io.gs2.cdk.buff.model.enums.BuffEntryModelTargetType.MODEL,
                    3,
                    new io.gs2.cdk.buff.model.options.BuffEntryModelOptions()
                        .withMetadata("BUFF_0003")
                        .withTargetModel(new io.gs2.cdk.buff.model.BuffTargetModel(
                            io.gs2.cdk.buff.model.enums.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            "rankCapValue",
                            Arrays.asList(
                                new io.gs2.cdk.buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
                                )
                            ),
                            3.0f
                        ))
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Buff.Model.Namespace(
            stack: this,
            name: "namespace-0001"
        ).MasterData(
            new Gs2Cdk.Gs2Buff.Model.BuffEntryModel[] {
                new Gs2Cdk.Gs2Buff.Model.BuffEntryModel(
                    name: "buff-0001",
                    expression: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelExpression.RateAdd,
                    targetType: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelTargetType.Model,
                    priority: 1,
                    options: new Gs2Cdk.Gs2Buff.Model.Options.BuffEntryModelOptions
                    {
                        metadata = "BUFF_0001",
                        targetModel = new Gs2Cdk.Gs2Buff.Model.BuffTargetModel(
                            targetModelName: Gs2Cdk.Gs2Buff.Model.Enums.BuffTargetModelTargetModelName.Gs2ExperienceStatus,
                            targetFieldName: "rankCapValue",
                            conditionGrns: new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn[]
                            {
                                new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
                                ),
                                new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002"
                                )
                            },
                            rate: 1.0f
                        )
                    }
                ),
                new Gs2Cdk.Gs2Buff.Model.BuffEntryModel(
                    name: "buff-0002",
                    expression: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelExpression.Mul,
                    targetType: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelTargetType.Action,
                    priority: 2,
                    options: new Gs2Cdk.Gs2Buff.Model.Options.BuffEntryModelOptions
                    {
                        metadata = "BUFF_0002",
                        targetAction = new Gs2Cdk.Gs2Buff.Model.BuffTargetAction(
                            targetActionName: Gs2Cdk.Gs2Buff.Model.Enums.BuffTargetActionTargetActionName.Gs2ExperienceAddExperienceByUserId,
                            targetFieldName: "experienceValue",
                            conditionGrns: new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn[]
                            {
                                new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
                                )
                            },
                            rate: 2.0f
                        )
                    }
                ),
                new Gs2Cdk.Gs2Buff.Model.BuffEntryModel(
                    name: "buff-0003",
                    expression: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelExpression.Mul,
                    targetType: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelTargetType.Model,
                    priority: 3,
                    options: new Gs2Cdk.Gs2Buff.Model.Options.BuffEntryModelOptions
                    {
                        metadata = "BUFF_0003",
                        targetModel = new Gs2Cdk.Gs2Buff.Model.BuffTargetModel(
                            targetModelName: Gs2Cdk.Gs2Buff.Model.Enums.BuffTargetModelTargetModelName.Gs2ExperienceStatus,
                            targetFieldName: "rankCapValue",
                            conditionGrns: new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn[]
                            {
                                new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
                                )
                            },
                            rate: 3.0f
                        )
                    }
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template
import core from "@/gs2cdk/core";
import buff from "@/gs2cdk/buff";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new buff.model.Namespace(
            this,
            "namespace-0001",
        ).masterData(
            [
                new buff.model.BuffEntryModel(
                    "buff-0001",
                    buff.model.BuffEntryModelExpression.RATE_ADD,
                    buff.model.BuffEntryModelTargetType.MODEL,
                    1,
                    {
                        metadata: "BUFF_0001",
                        targetModel: new buff.model.BuffTargetModel(
                            buff.model.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            "rankCapValue",
                            [
                                new buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
                                ),
                                new buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002"
                                ),
                            ],
                            1.0
                        )
                    }
                ),
                new buff.model.BuffEntryModel(
                    "buff-0002",
                    buff.model.BuffEntryModelExpression.MUL,
                    buff.model.BuffEntryModelTargetType.ACTION,
                    2,
                    {
                        metadata: "BUFF_0002",
                        targetAction: new buff.model.BuffTargetAction(
                            buff.model.BuffTargetActionTargetActionName.GS2_EXPERIENCE_ADD_EXPERIENCE_BY_USER_ID,
                            "experienceValue",
                            [
                                new buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
                                ),
                            ],
                            2.0
                        )
                    }
                ),
                new buff.model.BuffEntryModel(
                    "buff-0003",
                    buff.model.BuffEntryModelExpression.MUL,
                    buff.model.BuffEntryModelTargetType.MODEL,
                    3,
                    {
                        metadata: "BUFF_0003",
                        targetModel: new buff.model.BuffTargetModel(
                            buff.model.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            "rankCapValue",
                            [
                                new buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
                                ),
                            ],
                            3.0
                        )
                    }
                )
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
from gs2_cdk import Stack, core, buff

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        buff.Namespace(
            stack=self,
            name="namespace-0001",
        ).master_data(
            buff_entry_models=[
                buff.BuffEntryModel(
                    name='buff-0001',
                    expression=buff.BuffEntryModelExpression.RATE_ADD,
                    target_type=buff.BuffEntryModelTargetType.MODEL,
                    priority=1,
                    options=buff.BuffEntryModelOptions(
                        metadata = 'BUFF_0001',
                        target_model = buff.BuffTargetModel(
                            target_model_name=buff.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            target_field_name='rankCapValue',
                            condition_grns=[
                                buff.BuffTargetGrn(
                                    target_model_name='Gs2Experience:ExperienceModel',
                                    target_grn='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001',
                                ),
                                buff.BuffTargetGrn(
                                    target_model_name='Gs2Experience:ExperienceModel',
                                    target_grn='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002',
                                ),
                            ],
                            rate=1.0,
                        )
                    ),
                ),
                buff.BuffEntryModel(
                    name='buff-0002',
                    expression=buff.BuffEntryModelExpression.MUL,
                    target_type=buff.BuffEntryModelTargetType.ACTION,
                    priority=2,
                    options=buff.BuffEntryModelOptions(
                        metadata = 'BUFF_0002',
                        target_action = buff.BuffTargetAction(
                            target_action_name=buff.BuffTargetActionTargetActionName.GS2_EXPERIENCE_ADD_EXPERIENCE_BY_USER_ID,
                            target_field_name='experienceValue',
                            condition_grns=[
                                buff.BuffTargetGrn(
                                    target_model_name='Gs2Experience:ExperienceModel',
                                    target_grn='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001',
                                ),
                            ],
                            rate=2.0,
                        )
                    ),
                ),
                buff.BuffEntryModel(
                    name='buff-0003',
                    expression=buff.BuffEntryModelExpression.MUL,
                    target_type=buff.BuffEntryModelTargetType.MODEL,
                    priority=3,
                    options=buff.BuffEntryModelOptions(
                        metadata = 'BUFF_0003',
                        target_model = buff.BuffTargetModel(
                            target_model_name=buff.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            target_field_name='rankCapValue',
                            condition_grns=[
                                buff.BuffTargetGrn(
                                    target_model_name='Gs2Experience:ExperienceModel',
                                    target_grn='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001',
                                ),
                            ],
                            rate=3.0,
                        )
                    ),
                ),
            ],
        )

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

BuffEntryModel

버프 엔트리 모델

버프의 적용량은 버프 엔트리 모델로 관리하며, 동일한 대상에 대해 여러 버프 엔트리 모델을 연결할 수 있습니다.
버프 엔트리 모델의 적용 순서는 버프 엔트리 모델의 priority 로 관리하며, priority 값이 작을수록 우선순위가 높아집니다.

버프의 적용 방식은 3종류가 있으며 “Rate Add”, “Mul”, “Value Add"가 있습니다.
Rate Add 는 버프의 적용 레이트에 가산하는 명령이며, Mul 은 버프의 적용 레이트에 곱하는 명령입니다.
Value Add 는 버프 보정 계산 후의 값에 가산을 수행하는 명령입니다.
예를 들어 기본 레이트가 1.0 이고 Rate Add 0.2 를 설정하면 버프 적용 레이트는 1.2 가 됩니다.
Mul 0.5 를 설정하면 버프 적용 레이트는 현재 레이트의 0.5배가 됩니다.

버프 엔트리 모델에는 GS2-Schedule 의 이벤트를 연결할 수 있으며, 이벤트 개최 기간 중에만 버프를 적용하도록 설정하는 것도 가능합니다.

타입활성화 조건필수기본값값 제한설명
buffEntryModelIdstring
~ 1024자버프 엔트리 모델 GRN
※ 서버가 자동으로 설정
namestring
~ 128자버프 엔트리 모델 이름
버프 엔트리 모델 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
metadatastring~ 2048자메타데이터
메타데이터에는 임의의 값을 설정할 수 있습니다.
이 값들은 GS2의 동작에는 영향을 주지 않으므로, 게임 내에서 사용하는 정보를 저장하는 용도로 사용할 수 있습니다.
expression문자열 열거형
enum {
  “rate_add”,
  “mul”,
  “value_add”
}
버프의 적용 타입
버프 값을 대상에 어떻게 적용할지를 지정합니다. “Rate Add"는 보정 레이트에 가산(예: 1.0 + 0.2 = 1.2), “Mul"은 보정 레이트에 곱함(예: 레이트 * 0.5), “Value Add"는 레이트 기반 보정 계산 후의 값에 직접 가산합니다.
정의설명
rate_add보정 레이트에 가산
mul보정 레이트에 곱함
value_add값을 직접 가산(모델이나 액션의 숫자 값만)
targetType문자열 열거형
enum {
  “model”,
  “action”
}
버프를 적용할 대상의 종류
버프를 모델의 필드 값에 적용할지, 액션의 파라미터에 적용할지를 지정합니다. “Model"은 GS2 리소스 모델의 필드를 대상으로 하며, “Action"은 GS2 액션(예: 획득량이나 소비량)의 파라미터를 대상으로 합니다.
정의설명
model모델
action액션
targetModelBuffTargetModel{targetType} == “model”
✓※
버프를 적용할 대상 모델
버프를 적용할 GS2 리소스 모델과 필드를 지정합니다. 모델 이름, 필드 이름, 대상 리소스를 특정하는 조건 GRN, 그리고 레이트 값이 포함됩니다.
※ targetType이(가) “model” 이면 필수
targetActionBuffTargetAction{targetType} == “action”
✓※
버프를 적용할 대상 액션
버프를 적용할 GS2 액션과 파라미터를 지정합니다. 액션 이름, 필드 이름, 대상 리소스를 특정하는 조건 GRN, 그리고 레이트 값이 포함됩니다.
※ targetType이(가) “action” 이면 필수
priorityint
0 ~ 2147483646버프의 적용 우선순위
버프 엔트리 모델이 평가되는 순서를 결정합니다. 값이 작을수록 먼저 평가됩니다. 동일한 필드를 대상으로 하는 여러 버프가 있는 경우, Rate Add 와 Mul 연산의 상호작용으로 인해 적용 순서가 최종 결과에 영향을 미칩니다.
applyPeriodScheduleEventIdstring~ 1024자버프를 적용할 이벤트의 개최 기간 GRN
이 버프의 유효 기간을 제어하는 GS2-Schedule 이벤트의 GRN입니다. 지정한 경우, 이벤트 개최 기간 중에만 버프가 적용됩니다. 지정하지 않은 경우, 버프는 항상 유효합니다.

BuffTargetModel

버프 적용 대상 모델

버프 적용의 대상이 되는 GS2 리소스 모델과 필드를 정의합니다. 어떤 모델의 어떤 필드 값을 버프로 변경할지 지정하며, 대상 리소스 인스턴스를 특정하는 조건 GRN과 적용할 레이트 값을 포함합니다.

타입활성화 조건필수기본값값 제한설명
targetModelName문자열 열거형
enum {
}
버프를 적용할 모델의 종류
targetFieldNamestring
~ 64자버프 적용 대상 필드명
버프에 의해 값이 변경되는 대상 모델 상의 수치 필드명입니다. 예를 들어 경험치나 공격력 등의 수치 속성을 나타내는 필드가 대상이 됩니다.
conditionGrnsList<BuffTargetGrn>
1 ~ 10 items버프 적용 조건 GRN 목록
버프 적용의 대상 리소스 인스턴스를 특정하는 GRN 패턴의 목록입니다. 여러 GRN을 조합하여 리소스를 정확하게 특정하는 복합 조건을 구성합니다.
ratefloat
0 ~ 1000000보정 레이트
적용되는 버프 값입니다. 적용 타입에 따라 의미가 다릅니다. “Rate Add"의 경우 기본 레이트에 가산, “Mul"의 경우 현재 레이트에 곱셈, “Value Add"의 경우 레이트 계산 후의 필드 값에 직접 가산됩니다.

BuffTargetAction

버프 적용 대상 액션

버프 적용의 대상이 되는 GS2 액션과 파라미터를 정의합니다. 어떤 액션의 어떤 파라미터를 버프로 변경할지 지정하며, 대상 리소스 인스턴스를 특정하는 조건 GRN과 적용할 레이트 값을 포함합니다.

타입활성화 조건필수기본값값 제한설명
targetActionName문자열 열거형
enum {
"Gs2Experience:AddExperienceByUserId",
"Gs2Experience:SubExperience",
"Gs2Experience:SubExperienceByUserId",
"Gs2Inventory:AcquireItemSetByUserId",
"Gs2Inventory:ConsumeItemSet",
"Gs2Inventory:ConsumeItemSetByUserId",
"Gs2Inventory:AcquireSimpleItemsByUserId",
"Gs2Inventory:ConsumeSimpleItems",
"Gs2Inventory:ConsumeSimpleItemsByUserId",
"Gs2Inventory:AcquireBigItemByUserId",
"Gs2Inventory:ConsumeBigItem",
"Gs2Inventory:ConsumeBigItemByUserId",
"Gs2Limit:CountUp",
"Gs2Limit:CountUpByUserId",
"Gs2Money:DepositByUserId",
"Gs2Money:Withdraw",
"Gs2Money:WithdrawByUserId",
"Gs2Money2:DepositByUserId",
"Gs2Money2:Withdraw",
"Gs2Money2:WithdrawByUserId",
"Gs2Stamina:ConsumeStamina",
"Gs2Stamina:ConsumeStaminaByUserId",
"Gs2Stamina:RecoverStaminaByUserId",
}
버프를 적용할 액션의 종류
targetFieldNamestring
~ 64자버프 적용 대상 필드명
버프에 의해 값이 변경되는 대상 액션 상의 수치 파라미터명입니다. 예를 들어 입수 수량, 소비량, 보상 수량 등을 나타내는 파라미터가 대상이 됩니다.
conditionGrnsList<BuffTargetGrn>
1 ~ 10 items버프 적용 조건 GRN 목록
버프 적용의 대상 리소스 인스턴스를 특정하는 GRN 패턴의 목록입니다. 여러 GRN을 조합하여 리소스를 정확하게 특정하는 복합 조건을 구성합니다.
ratefloat
0 ~ 1000000보정 레이트
적용되는 버프 값입니다. 적용 타입에 따라 의미가 다릅니다. “Rate Add"의 경우 기본 레이트에 가산, “Mul"의 경우 현재 레이트에 곱셈, “Value Add"의 경우 레이트 계산 후의 파라미터 값에 직접 가산됩니다.

BuffTargetGrn

버프 적용 조건이 되는 리소스의 GRN 패턴

버프가 유효해지는 리소스 인스턴스를 좁히기 위한 조건 GRN 패턴입니다.
targetModelName 으로 GS2 서비스 모델의 종류를 특정하며, targetGrn 에는 런타임에 해결되는 컨텍스트 변수({region}, {ownerId})를 포함할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
targetModelNamestring
~ 64자버프 적용 조건의 모델 이름
조건 GRN을 해결하기 위해 사용되는 GS2 서비스 모델의 이름입니다. GRN 패턴이 어느 서비스의 리소스 모델을 참조하는지를 특정합니다.
targetGrnstring
~ 1024자버프의 적용 조건 GRN
런타임에 해결되는 컨텍스트 플레이스홀더(예: {region}, {ownerId})를 포함한 GRN 템플릿입니다. 버프의 대상이 되는 특정 리소스 인스턴스를 특정하기 위해 사용됩니다.