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

Data Segment API #2273

Closed
wants to merge 2 commits into from
Closed

Data Segment API #2273

wants to merge 2 commits into from

Conversation

codebien
Copy link
Contributor

This PR adds the primitives for accessing the execution segment info useful for data partitioning. It mostly adds the x/segment extension to the core.

This PR still lacks in terms of testing coverage, it's more a PoC PR for getting an agreement about the API and the use cases it should cover.

A basic example about how it's expected to be used:

// the essential part exported from the `samples/segmented-index.js` sample 
import { SharedSegmentedIndex } from 'k6/segment';

export default function () {
    let iterator = new SharedSegmentedIndex('myarr');
    let index = iterator.next();

    const reqBody = JSON.stringify(data[index.unscaled]);
    var res = http.post('https://httpbin.test.k6.io/anything', reqBody, params);
    check(res, { 'status 200': (r) => r.status === 200 });

    console.log(`Something: ${res.json().json.something}`)
}

running it with the following command:

k6 run -i 5 --execution-segment "0:1/2" --execution-segment-sequence "0,1/2,1" ./samples/segmented-index.js

the expected console output:

INFO[0001] Something: something else 1                   source=console
INFO[0001] Something: something else 3                   source=console
INFO[0001] Something: something else 5                   source=console
INFO[0001] Something: something else 7                   source=console
INFO[0002] Something: something else 9                   source=console

Questions

  • Does it require a dedicated module? I think it could be directly part of k6/data.
  • Do we expect the users will use both scaled and unscaled?
  • GoTo is exported, how do we expect to use it?

@codebien codebien self-assigned this Nov 30, 2021
@github-actions github-actions bot requested review from na-- and oleiade November 30, 2021 17:19
@codebien codebien requested a review from mstoykov November 30, 2021 17:19
@oleiade
Copy link
Member

oleiade commented Dec 13, 2021

In the spirit of putting the review in context: I'd be keen to understand what's the use case/user scenario this addresses? Is there an issue giving some context opened somewhere? Cheers 😄

@codebien
Copy link
Contributor Author

In the spirit of putting the review in context

Yep, sorry, I missed it in the description. It's a first iteration for #1539

@codebien
Copy link
Contributor Author

Let's move back to Draft because after a discussion with @mstoykov we identified that this requires more discussion and API definition in the issue before starting reviewing it.

@codebien codebien marked this pull request as draft December 22, 2021 15:39
@na-- na-- added this to the v0.37.0 milestone Jan 5, 2022
@codebien codebien removed this from the v0.37.0 milestone Feb 23, 2022
@codebien
Copy link
Contributor Author

At the moment, this PR doesn't fit our expectations, so I'm closing it.

@codebien codebien closed this Mar 18, 2022
@na-- na-- deleted the data-segment-api branch March 23, 2022 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants