Skip to content

Add bucket_id calculation function #76

@Totktonada

Description

@Totktonada

After #71 we'll have all information that is necessary for calculating bucket_id by a sharding key. The proposal is to implement this helper function in the module.

Example

Schema:

TBD

Assume we serve HTTP requests:

function handler(req)
    local bucket_id = ddl.bucket_id('users', req:json()['user_id'])
    local ok, err = vshard.router.callrw(bucket_id, <..args..>)
    <...>
end

The key point is that ddl knows, which sharding function is is use. Without the function we would do the following:

function handler(req)
    local bucket_id = vshard.router.bucket_id_mpcrc32(req:json()['user_id']) -- !!
    local ok, err = vshard.router.callrw(bucket_id, <..args..>)
    <...>
end

Metadata

Metadata

Assignees

Labels

featureA new functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions