Skip to content

[💡 Feature]: shared-store atomic operations #10010

@pedrorfernandes

Description

@pedrorfernandes

Is your feature request related to a problem?

I have a test scenario where I need to access specific url's, e.g.: ['url01.com', 'url02.com', 'url03.com']

The wdio workers should share these URL's and never clash. Once a worker is finished, it "frees" up that url for another worker.

Possibly a better way to handle this is through network/load balancing, however I wanted to try this with shared-data service, setting up the url sharing between workers:

// worker A
await getValue("*"); // { 'url01.com': true, 'url02.com': true } booleans represent isUrlAvailable

// worker B
await getValue("*"); // { 'url01.com': true, 'url02.com': true }

// worker A chooses `url01.com`
await setValue("url01.com", false)
// worker B chooses `url01.com`
await setValue("url01.com", false)

// both A + B workers now have the same URL
// clash !

This is basically a shared queue management problem between node worker threads

Describe the solution you'd like.

I could implement in shared-store another server operation '/compareAndSet' to avoid collisions when writing data

compareAndSet(key, expectedValue, newValue) only sets newValue if expectedValue is the current value in the store

// worker A
await getValue("*"); // { 'url01.com': true, 'url02.com': true }

// worker B
await getValue("*"); // { 'url01.com': true, 'url02.com': true }

// worker A chooses `url01.com`
await compareAndSet("url01.com", true, false)
// worker B chooses `url01.com`
await compareAndSet("url01.com", true, false) // throws error, 'url01.com' is not `=== true` anymore
// worker B must retry another value

Describe alternatives you've considered.

I thought about a different service where we just configure a queue of resources to be shared [1, 2, 3, 4] and the operations would just be /take a resource and /return a resource, this is easier on the beforeSession for each worker since the server would automatically dispense the value the worker needs and it doesn't need to retry until a value is free

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

Idea 💡A new feature ideafirst-timers-onlyIssues that are well described and directed for people that start contributing to the projecthelp wantedIssues that are free to take by anyone interested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions