Service - Account Limits: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
(Created page with "= Overview = Controls a user's limits for actions based on their roles set in Service - RBAC = Repository = https://bitbucket.org/izara-core-user-accounts/izara-core-user-accounts-account-limits/src/master/ = DynamoDB tables = == Standard Config Table Per Service == === Configuration tags === <syntaxhighlight lang="JavaScript"> { configKey: "MediaGraphServiceName" configTag: "MediaGraphServiceName" configValue: xxx // eg: "MediaGraph" } </syntaxhighligh...")
 
 
(15 intermediate revisions by 2 users not shown)
Line 2: Line 2:


Controls a user's limits for actions based on their roles set in [[Service - RBAC]]
Controls a user's limits for actions based on their roles set in [[Service - RBAC]]
* Works out each user’s site limits according to the user’s app_level RBAC roles
* Records user’s usage for counted limit types


= Repository =
= Repository =
Line 15: Line 18:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
configKey: "MediaGraphServiceName"
configKey: "RbacServiceName"
configTag: "MediaGraphServiceName"
configTag: "RbacServiceName"
configValue: xxx // eg: "MediaGraph"
configValue: xxx // eg: "RBAC"
}
}
</syntaxhighlight>
</syntaxhighlight>
== RoleLimit ==
Sets the limits applied to each role


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
configKey: "MediaHandlerService"
roleLimitId: xxx
configTag: xxx // mediaHandlerServiceNameTag, eg: "MediaStandard", this is what is saved in each media node
limitType: xxx
configValue: {
limitValue: xxx
serviceName: xxx // eg: "ImageStandard", this is the actual deployed service name}
}
}
}
</syntaxhighlight>
</syntaxhighlight>


== MediaRecord ==
* partition key: roleLimitId
* sort key: limitType
* roleLimitId: roleId + "_" + "limitTag"
* limitType is "static"|"timeBasedDynamic"|"runningTotal", if timeBasedDynamic also concatenate "_" + limitUnit
* limitUnit: for timeBased limitType, eg: "days"|"hours"|...


Records which Handler manages each media element
== TimeBasedDynamicUsage ==


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
mediaId
dynamicUsageId: xxx
mediaHandlerServiceNameTag
usedTimestampId: xxx
usageCount: xxx // integer
decreaseUsage: true // if increase not add this attribute
timeBasedUsageStatus: reserved|confirmed|cancelled
}
}
</syntaxhighlight>
</syntaxhighlight>


* partition key: mediaId
* partition key: dynamicUsageId
* sort key: (none)
* sortKey: usedTimestampId
 
* dynamicUsageId: userId + "_" + limitTag
= Graph database =
* usedTimestampId: {timestamp reserved use}_{uniqueRequestId}, add uniqueRequestId to ensure each request is unique
 
* count allows more than 1 usage to be applied per request
== [[Service - Media Graph]]==
 
=== Nodes ===


== RunningTotalUsage ==


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
nodeLabel: "media",
userId: xxx
schema: {
limitTag: xxx
identifier: true,
totalCount: xxx // integer
restrictProperties: true,
updateUuid: xxx // random number, used in conditional when updating count to protect against race conditions
restrictRelationships: true,
properties: {
mediaId: {
identifier: true, // create unique id from request details
},
mediaHandlerServiceNameTag: {
immutable: true,
},
},
}
}
}
</syntaxhighlight>
</syntaxhighlight>
* Partition key could possibly be userId + "_" + limitTag with no sort key
== RunningTotalReservedUsage ==


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
nodeLabel: "mediaPropertyLabel",
runningTotalReservedId: xxx
}
usedTimestampId: xxx
{
usageCount: xxx // integer
nodeLabel: "mediaProperty",
decreaseUsage: true // if increase not add this attribute
runningTotalUsageStatus: reserved|confirmed|cancelled
}
}
</syntaxhighlight>
</syntaxhighlight>
* see [[NPM module - Izara Core - Property Node|DataSchemaLib]]


=== Relationships ===
* partition key: runningTotalReservedId
* sortKey: usedTimestampId
* runningTotalReservedId: userId + "_" + limitTag
* usedTimestampId: {timestamp sent with request}_{uniqueRequestId}, this allows us to check idempotence and not reserve same request multiple times
* count allows more than 1 usage to be applied per request
* records are not deleted once they are confirmed or cancelled, so a record is kept of changes
 
= Limit types =


<syntaxhighlight lang="JavaScript">
== static limits ==
{
 
relationshipType: "has_mediaProperty",
* limits that are fixed
}
* eg size limit for an uploaded photo or video.
{
* static limits do not need to record usage by each user
relationshipType: "disabled_mediaProperty",
 
}
== time based limits ==
{
 
relationshipType: "is_mediaPropertyLabel",
* eg number of products can list per day.
}
* have a record of usage
</syntaxhighlight>
* when the user attempts to perform action it is checked first to not exceed their limit, then the use is reserved, once the client service completes the action the use is confirmed
* see [[NPM module - Izara Core - Property Node|DataSchemaLib]]
* timeBasedDynamic: counts usage over the last period, counted from the time the request to perform the use is made
* Might need a cleanup process to remove really old records as not used after period passes
 
== running total limits ==
 
* Maximum number of times an action can be performed
* eg maximum number of products a user can list.
* usage is counted but not time based
* can be added to or subtracted from
* eg: storage_space_used
* has process to reserve usage
 
= FindData in RBAC =


== Basic node schemas ==
Use FindData in RBAC to find a users current limits, this will allow for cacheing and can add to tables/SearchResults etc..


Schema comes from [[NPM module - Izara Core - Property Node|BasicNodeSchemaLib]]
= Ideas =


# mediaPropertyLabel
* Currently thinking cannot have per user overwrites, can create roles to affect limits
#* [[Service - Translations Graph]]
* Could have per user/catalog limits too, probably as separate Account Limit services
# mediaProperty
* another possible time based limit: (can add later) time_based_period: has a set time when the count is reset, eg: per day, count resetting at midnight
#* [[Service - Translations Graph]]


= Working documents =
= Working documents =


[[:Category:Working_documents - Media Manager|Media Manager]]
[[:Category:Working_documents - Account Limits|Account Limits]]


[[Category:Backend services| Media Manager]]
[[Category:Backend services| Account Limits]]

Latest revision as of 09:42, 4 May 2023

Overview

Controls a user's limits for actions based on their roles set in Service - RBAC

  • Works out each user’s site limits according to the user’s app_level RBAC roles
  • Records user’s usage for counted limit types

Repository

https://bitbucket.org/izara-core-user-accounts/izara-core-user-accounts-account-limits/src/master/

DynamoDB tables

Standard Config Table Per Service

Configuration tags

{
	configKey: "RbacServiceName"
	configTag: "RbacServiceName"
	configValue: xxx // eg: "RBAC"
}

RoleLimit

Sets the limits applied to each role

{
	roleLimitId: xxx
	limitType: xxx
	limitValue: xxx
}
  • partition key: roleLimitId
  • sort key: limitType
  • roleLimitId: roleId + "_" + "limitTag"
  • limitType is "static"|"timeBasedDynamic"|"runningTotal", if timeBasedDynamic also concatenate "_" + limitUnit
  • limitUnit: for timeBased limitType, eg: "days"|"hours"|...

TimeBasedDynamicUsage

{
	dynamicUsageId: xxx
	usedTimestampId: xxx
	usageCount: xxx // integer
	decreaseUsage: true // if increase not add this attribute
	timeBasedUsageStatus: reserved|confirmed|cancelled
}
  • partition key: dynamicUsageId
  • sortKey: usedTimestampId
  • dynamicUsageId: userId + "_" + limitTag
  • usedTimestampId: {timestamp reserved use}_{uniqueRequestId}, add uniqueRequestId to ensure each request is unique
  • count allows more than 1 usage to be applied per request

RunningTotalUsage

{
	userId: xxx
	limitTag: xxx
	totalCount: xxx // integer
	updateUuid: xxx // random number, used in conditional when updating count to protect against race conditions
}
  • Partition key could possibly be userId + "_" + limitTag with no sort key

RunningTotalReservedUsage

{
	runningTotalReservedId: xxx
	usedTimestampId: xxx
	usageCount: xxx // integer
	decreaseUsage: true // if increase not add this attribute
	runningTotalUsageStatus: reserved|confirmed|cancelled
}
  • partition key: runningTotalReservedId
  • sortKey: usedTimestampId
  • runningTotalReservedId: userId + "_" + limitTag
  • usedTimestampId: {timestamp sent with request}_{uniqueRequestId}, this allows us to check idempotence and not reserve same request multiple times
  • count allows more than 1 usage to be applied per request
  • records are not deleted once they are confirmed or cancelled, so a record is kept of changes

Limit types

static limits

  • limits that are fixed
  • eg size limit for an uploaded photo or video.
  • static limits do not need to record usage by each user

time based limits

  • eg number of products can list per day.
  • have a record of usage
  • when the user attempts to perform action it is checked first to not exceed their limit, then the use is reserved, once the client service completes the action the use is confirmed
  • timeBasedDynamic: counts usage over the last period, counted from the time the request to perform the use is made
  • Might need a cleanup process to remove really old records as not used after period passes

running total limits

  • Maximum number of times an action can be performed
  • eg maximum number of products a user can list.
  • usage is counted but not time based
  • can be added to or subtracted from
  • eg: storage_space_used
  • has process to reserve usage

FindData in RBAC

Use FindData in RBAC to find a users current limits, this will allow for cacheing and can add to tables/SearchResults etc..

Ideas

  • Currently thinking cannot have per user overwrites, can create roles to affect limits
  • Could have per user/catalog limits too, probably as separate Account Limit services
  • another possible time based limit: (can add later) time_based_period: has a set time when the count is reset, eg: per day, count resetting at midnight

Working documents

Account Limits