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

Fix getlift/lift#208, allow for batchSize above 10 #317

Merged
merged 1 commit into from
Jun 16, 2023

Conversation

joawan
Copy link
Contributor

@joawan joawan commented Mar 17, 2023

AWS allows for batchSize up to 10k for non-FIFO queues where you have also set a maxBatchWindow.

@fredericbarthelet
Copy link
Collaborator

fredericbarthelet commented Mar 22, 2023

Hi @joawan and thanks for the contribution :)

I was working on an exemple code snippet to showcase how to achieve the same functionality without relying on additional programmatic code within the Construct constructor, but relying solely on the JSON schema definition for the construct :

const QUEUE_DEFINITION = {
    type: "object",
    properties: {
        type: { const: "queue" },
        worker: {
            type: "object",
            properties: {
                timeout: { type: "number" },
            },
            additionalProperties: true,
        },
        maxRetries: { type: "number" },
        alarm: { type: "string" },
        batchSize: {
            type: "number",
            minimum: 1,
        },
        maxBatchingWindow: {
            type: "number",
            maximum: 300,
        },
        fifo: { type: "boolean" },
        delay: { type: "number" },
        encryption: { type: "string" },
        encryptionKey: { type: "string" },
    },
    oneOf: [
        {
            // For FIFO queues, the maximum batch size is 10
            properties: {
                fifo: { const: true },
                batchSize: {
                    type: "number",
                    maximum: 10,
                },
            },
        },
        {
            // When specifying a batch size larger than 10, maxBatchingWindow must be larger than 1
            properties: {
                batchSize: {
                    type: "number",
                    minimum: 11,
                    maximum: 10000,
                },
                maxBatchingWindow: {
                    type: "number",
                    minimum: 1,
                },
            },
            required: ["maxBatchingWindow"],
        },
    ],
    additionalProperties: false,
    required: ["worker"],
} as const;

This has the advantage to leverage existing validation functionalities without requiring additional cyclomatic complexity in the construct. WDYT ?

@joawan
Copy link
Contributor Author

joawan commented Mar 22, 2023

Looks way better!

@fredericbarthelet
Copy link
Collaborator

Hi @joawan, are you still up to update your PR with my recommendation :) ?
I can do the update myself, but you have the original idea and deserve the credit adding this feature to Lift ;)

@joawan
Copy link
Contributor Author

joawan commented Mar 28, 2023

No no, your code, you update :)

@joawan
Copy link
Contributor Author

joawan commented Apr 4, 2023

Tried updating using your suggestion but then tests won't pass.
Getting stuck on SQS visibility test

@joawan
Copy link
Contributor Author

joawan commented Apr 17, 2023

@mnapoli Any chance of getting this one in?

@mnapoli
Copy link
Member

mnapoli commented Jun 16, 2023

Let's get this shipped! Thanks for the PR!

@mnapoli mnapoli merged commit 1e786ed into getlift:master Jun 16, 2023
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.

None yet

3 participants