GS2-Schedule Transaction Actions
Combining actions, and concurrency
The background common to every service is collected in Combining Transaction Actions. Read that first; the rest of this section is what GS2-Schedule adds to it.
The transaction actions of GS2-Schedule address one trigger, identified by the combination of namespace, user, and trigger name. A trigger is rewritten as a whole on every update.
| Operation | Repeated in one transaction | Across a nested transaction | Boundary that separates targets |
|---|---|---|---|
Pulling a triggerTriggerByUserId | Combined into one | Fails | namespace, user, trigger name |
Extending a triggerExtendTriggerByUserId | Combined, and the seconds are added up | Fails | namespace, user, trigger name |
Deleting a triggerDeleteTriggerByUserId | Combined into one | Fails | namespace, user, trigger name |
Verifying a triggerVerifyTriggerByUserId | First wins | No collision, because it only reads | trigger, verify type, elapsed time |
Verifying an eventVerifyEventByUserId | First wins | No collision, because it only reads | event, verify type, user |
Pulling, extending, and deleting are three separate rows sharing a boundary, so placing two of them against one trigger collides. Wanting to pull a trigger and then extend it is a common request, but it takes two transactions: extending works from the state at the start of the transaction, so it cannot see a trigger the same transaction pulled.
Verify actions look at the state as of the start of the transaction. You cannot verify a trigger that the same transaction pulled, or one it deleted.
Whether an event is running depends on the time offset, which is per user, so an event verification is a different target for each user.
Take care with nested transactions
A trigger is rewritten as a whole, so a trigger pulled from the inside collides with the same trigger extended or deleted from the outside, and the transaction fails.
If you want to avoid these restrictions
Pulling and extending a trigger are acquire actions; deleting one is a consume action. Turning acquireActionUseJobQueue on clears a collision between a pull and an extend, but a collision with a delete needs enableAtomicCommit turned off.
Concurrency and retries
A trigger is rewritten as a whole with a revision check, so when several requests update the same trigger at the same time, the one confirmed later returns a conflict (409). Nothing is wrong with the request, so retrying will succeed.
A different trigger name is a different target, so requests for different triggers do not conflict.
Verify Action
Gs2Schedule:VerifyTriggerByUserId
Verify the elapsed time since the Trigger was pulled by User ID
Verifies conditions related to the trigger’s state for the specified user. The verifyType can be: ’notTriggerd’, ’elapsed’, or ’notElapsed’. Returns an error if the verification condition is not met.
Quantity specification supported: NO
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||||
| userId | string | ✓ | ~ 128 chars | User ID Specify #{userId} to substitute the currently logged-in user’s ID. | ||||||||||
| triggerName | string | ✓ | ~ 128 chars | Trigger name Unique Trigger name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||||
| verifyType | string (enum) enum { “notTriggerd”, “elapsed”, “notElapsed” } | ✓ | Type of verification
| |||||||||||
| elapsedMinutes | int | {verifyType} in [“elapsed”, “notElapsed”] | ✓* | 0 ~ 2147483646 | Elapsed time (minutes) * Required if verifyType is “elapsed”,“notElapsed” | |||||||||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
{
"action": "Gs2Schedule:VerifyTriggerByUserId",
"request": {
"namespaceName": "[string]Namespace name",
"userId": "[string]User ID",
"triggerName": "[string]Trigger name",
"verifyType": "[string]Type of verification",
"elapsedMinutes": "[int]Elapsed time (minutes)",
"timeOffsetToken": "[string]Time offset token"
}
}action: Gs2Schedule:VerifyTriggerByUserId
request:
namespaceName: "[string]Namespace name"
userId: "[string]User ID"
triggerName: "[string]Trigger name"
verifyType: "[string]Type of verification"
elapsedMinutes: "[int]Elapsed time (minutes)"
timeOffsetToken: "[string]Time offset token"transaction.service("schedule").verify.verify_trigger_by_user_id({
namespaceName="[string]Namespace name",
userId="[string]User ID",
triggerName="[string]Trigger name",
verifyType="[string]Type of verification",
elapsedMinutes="[int]Elapsed time (minutes)",
timeOffsetToken="[string]Time offset token",
})Gs2Schedule:VerifyEventByUserId
Verify whether the Event is active by User ID
Verifies whether the specified event is currently in its active schedule period for the specified user. The verifyType can be set to ‘inSchedule’ or ’notInSchedule’. Returns an error if the verification condition is not met.
Quantity specification supported: NO
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| userId | string | ✓ | ~ 128 chars | User ID Specify #{userId} to substitute the currently logged-in user’s ID. | ||||||||
| eventName | string | ✓ | ~ 128 chars | Event name Unique Event name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| verifyType | string (enum) enum { “inSchedule”, “notInSchedule” } | ✓ | Type of verification
| |||||||||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
{
"action": "Gs2Schedule:VerifyEventByUserId",
"request": {
"namespaceName": "[string]Namespace name",
"userId": "[string]User ID",
"eventName": "[string]Event name",
"verifyType": "[string]Type of verification",
"timeOffsetToken": "[string]Time offset token"
}
}action: Gs2Schedule:VerifyEventByUserId
request:
namespaceName: "[string]Namespace name"
userId: "[string]User ID"
eventName: "[string]Event name"
verifyType: "[string]Type of verification"
timeOffsetToken: "[string]Time offset token"transaction.service("schedule").verify.verify_event_by_user_id({
namespaceName="[string]Namespace name",
userId="[string]User ID",
eventName="[string]Event name",
verifyType="[string]Type of verification",
timeOffsetToken="[string]Time offset token",
})Consume Action
Gs2Schedule:DeleteTriggerByUserId
Delete Trigger by User ID
Deletes the specified trigger for the specified user. Deleting a trigger deactivates associated relative schedule events.
Quantity specification supported: NO
Reversible action: NO
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID Specify #{userId} to substitute the currently logged-in user’s ID. | ||
| triggerName | string | ✓ | ~ 128 chars | Trigger name Unique Trigger name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
{
"action": "Gs2Schedule:DeleteTriggerByUserId",
"request": {
"namespaceName": "[string]Namespace name",
"userId": "[string]User ID",
"triggerName": "[string]Trigger name",
"timeOffsetToken": "[string]Time offset token"
}
}action: Gs2Schedule:DeleteTriggerByUserId
request:
namespaceName: "[string]Namespace name"
userId: "[string]User ID"
triggerName: "[string]Trigger name"
timeOffsetToken: "[string]Time offset token"transaction.service("schedule").consume.delete_trigger_by_user_id({
namespaceName="[string]Namespace name",
userId="[string]User ID",
triggerName="[string]Trigger name",
timeOffsetToken="[string]Time offset token",
})Acquire Action
Gs2Schedule:TriggerByUserId
Execute the Trigger by User ID
Pulls a trigger for the specified user. The trigger strategy determines behavior: ‘renew’ resets with new TTL, ’extend’ extends existing TTL, ‘drop’ ignores if already pulled, ‘repeatCycleEnd’/‘repeatCycleNextStart’/‘absoluteEnd’ aligns expiration with the specified event’s schedule. Pulling a trigger activates associated relative schedule events.
Quantity specification supported: NO
Reversible action: YES
| Type | Condition | Required | Default | Value Limits | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||||||||||
| triggerName | string | ✓ | ~ 128 chars | Trigger name Unique Trigger name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||||||||||
| userId | string | ✓ | ~ 128 chars | User ID Specify #{userId} to substitute the currently logged-in user’s ID. | ||||||||||||||||
| triggerStrategy | string (enum) enum { “renew”, “extend”, “drop”, “repeatCycleEnd”, “repeatCycleNextStart”, “absoluteEnd” } | ✓ | Trigger Execution Policy
| |||||||||||||||||
| ttl | int | {triggerStrategy} in [“renew”, “extend”, “drop”] | ✓* | 0 ~ 2147483646 | Trigger expiration time (seconds) * Required if triggerStrategy is “renew”,“extend”,“drop” | |||||||||||||||
| eventId | string | {triggerStrategy} in [“repeatCycleEnd”, “repeatCycleNextStart”, “absoluteEnd”] | ✓* | ~ 1024 chars | Event GRN
* Required if triggerStrategy is “repeatCycleEnd”,“repeatCycleNextStart”,“absoluteEnd” | |||||||||||||||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
{
"action": "Gs2Schedule:TriggerByUserId",
"request": {
"namespaceName": "[string]Namespace name",
"triggerName": "[string]Trigger name",
"userId": "[string]User ID",
"triggerStrategy": "[string]Trigger Execution Policy",
"ttl": "[int]Trigger expiration time (seconds)",
"eventId": "[string]Event GRN",
"timeOffsetToken": "[string]Time offset token"
}
}action: Gs2Schedule:TriggerByUserId
request:
namespaceName: "[string]Namespace name"
triggerName: "[string]Trigger name"
userId: "[string]User ID"
triggerStrategy: "[string]Trigger Execution Policy"
ttl: "[int]Trigger expiration time (seconds)"
eventId: "[string]Event GRN"
timeOffsetToken: "[string]Time offset token"transaction.service("schedule").acquire.trigger_by_user_id({
namespaceName="[string]Namespace name",
triggerName="[string]Trigger name",
userId="[string]User ID",
triggerStrategy="[string]Trigger Execution Policy",
ttl="[int]Trigger expiration time (seconds)",
eventId="[string]Event GRN",
timeOffsetToken="[string]Time offset token",
})Gs2Schedule:ExtendTriggerByUserId
Extend the period of a trigger by User ID
Extends the expiration period of an existing trigger for the specified user by the specified number of seconds. If the trigger does not exist, a new trigger is created with the specified extension period as its TTL.
Quantity specification supported: YES
Reversible action: NO
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| triggerName | string | ✓ | ~ 128 chars | Trigger name Unique Trigger name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID Specify #{userId} to substitute the currently logged-in user’s ID. | ||
| extendSeconds | int | ✓ | 0 ~ 2147483646 | Trigger extension period (seconds) | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
{
"action": "Gs2Schedule:ExtendTriggerByUserId",
"request": {
"namespaceName": "[string]Namespace name",
"triggerName": "[string]Trigger name",
"userId": "[string]User ID",
"extendSeconds": "[int]Trigger extension period (seconds)",
"timeOffsetToken": "[string]Time offset token"
}
}action: Gs2Schedule:ExtendTriggerByUserId
request:
namespaceName: "[string]Namespace name"
triggerName: "[string]Trigger name"
userId: "[string]User ID"
extendSeconds: "[int]Trigger extension period (seconds)"
timeOffsetToken: "[string]Time offset token"transaction.service("schedule").acquire.extend_trigger_by_user_id({
namespaceName="[string]Namespace name",
triggerName="[string]Trigger name",
userId="[string]User ID",
extendSeconds="[int]Trigger extension period (seconds)",
timeOffsetToken="[string]Time offset token",
})