Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern tags in group names #26

Closed
jirenius opened this issue Apr 30, 2019 · 1 comment
Closed

Pattern tags in group names #26

jirenius opened this issue Apr 30, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@jirenius
Copy link
Owner

Issue

It should be possible to use parts of the resource name when defining worker groups.

Example
Lets say we have a resource pattern, test.user.$userId, which might have sub-resources, test.user.$userId.roles.

If the data is stored and updated together, we might want only a single worker goroutine for each user and their sub-data. But in order not to have a single worker for all users, we need to be able to use the $userId part in the group ID.

Solution

Let groups contain tags, ${tagName}. The tagName must match a parameter in the resource pattern.

Example:

s.Handle("article.$id",
    res.Access(res.AccessGranted),
    res.GetModel(func(r res.ModelRequest) {
        article := getArticle(r.PathParam("id"))
        if article == nil {
            r.NotFound()
        } else {
            r.Model(article)
        }
    }),
    res.Group("group.article.${id}"),
)
@jirenius jirenius added the enhancement New feature or request label Apr 30, 2019
@jirenius jirenius self-assigned this Apr 30, 2019
jirenius added a commit that referenced this issue Apr 30, 2019
jirenius added a commit that referenced this issue Apr 30, 2019
@jirenius
Copy link
Owner Author

Resolved in #27

jirenius added a commit that referenced this issue May 6, 2019
…oup-names

GH-26: Added Resource and WithGroup methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant