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

Feat/batch templating #347

Merged
merged 13 commits into from
Jul 4, 2024
Merged

Feat/batch templating #347

merged 13 commits into from
Jul 4, 2024

Conversation

colmsnowplow
Copy link
Collaborator

@colmsnowplow colmsnowplow commented Jul 1, 2024

Refactors the HTTP target to handle batches of data in one go, adds the ability to provide a template to get those batches of data into a request body, and adds a helper function to cover the case where there is no template provided.

This involves breaking changes - the previous behaviour can be achieved by configuring a template if the data is already JSON, or a transformation + a template if not - but we don't believe there are any use cases requiring us to do so.

  • Refactors the http target to handle batches
  • Adds configuration of batch sizes for http target
  • Adds a templater function
  • Adds a helper function which creates a JSON array from the data where no template is provided
  • Adds a function to group data by dynamic headers where that is configured - to ensure that this feature still works
  • Adds tests for these features

These features also introduce a new possibility for failure in the HTTP target. The http target now expects valid JSON (previously it could be anything) - where we hit an error in either templating this data - or in the case of no template in transforming the data into a JSON array request body - these messages are treated as invalid, and will be sent to the failure target.

Comment on lines +349 to +351
for _, msg := range goodMsgs {
msg.TimeRequestStarted = requestStarted
msg.TimeRequestFinished = requestFinished
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting you do this even if err != nil

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's most valuable if err != nil! We introduced it on request from Tech Ops, because it tells us when lag/issues are most likely external :)

@colmsnowplow colmsnowplow force-pushed the feat/batch-templating branch from 4631cc7 to 853d9aa Compare July 4, 2024 15:56
colmsnowplow and others added 11 commits July 4, 2024 17:03
provideRequestBody can't be compatible with plain strings and play nicely with our data.

This commit changes it to expect a JSON - if there is some use case for plain strings it can still be done via a transformation + a template.
Won't be exact but will err on the side of caution since the template file's data will be _slightly_ bigger than the empty template.
@colmsnowplow colmsnowplow force-pushed the feat/batch-templating branch from 853d9aa to 07dc64e Compare July 4, 2024 16:06
@colmsnowplow colmsnowplow merged commit 72eb186 into develop Jul 4, 2024
1 check passed
@colmsnowplow colmsnowplow deleted the feat/batch-templating branch July 4, 2024 16:22
colmsnowplow added a commit that referenced this pull request Sep 11, 2024
Refactors the HTTP target to handle batches of data in one go, adds the ability to provide a template to get those batches of data into a request body, and adds a helper function to cover the case where there is no template provided.

This involves breaking changes - the previous behaviour can be achieved by configuring a template if the data is already JSON, or a transformation + a template if not - but we don't believe there are any use cases requiring us to do so.

- Refactors the http target to handle batches
- Adds configuration of batch sizes for http target
- Adds a templater function
- Adds a helper function which creates a JSON array from the data where no template is provided
- Adds a function to group data by dynamic headers where that is configured - to ensure that this feature still works
- Adds tests for these features

These features also introduce a new possibility for failure in the HTTP target. The http target now expects valid JSON (previously it could be anything) - where we hit an error in either templating this data - or in the case of no template in transforming the data into a JSON array request body - these messages are treated as invalid, and will be sent to the failure target.

---------

Co-authored-by: Piotr Poniedziałek <[email protected]>
pondzix added a commit that referenced this pull request Oct 25, 2024
Refactors the HTTP target to handle batches of data in one go, adds the ability to provide a template to get those batches of data into a request body, and adds a helper function to cover the case where there is no template provided.

This involves breaking changes - the previous behaviour can be achieved by configuring a template if the data is already JSON, or a transformation + a template if not - but we don't believe there are any use cases requiring us to do so.

- Refactors the http target to handle batches
- Adds configuration of batch sizes for http target
- Adds a templater function
- Adds a helper function which creates a JSON array from the data where no template is provided
- Adds a function to group data by dynamic headers where that is configured - to ensure that this feature still works
- Adds tests for these features

These features also introduce a new possibility for failure in the HTTP target. The http target now expects valid JSON (previously it could be anything) - where we hit an error in either templating this data - or in the case of no template in transforming the data into a JSON array request body - these messages are treated as invalid, and will be sent to the failure target.

---------

Co-authored-by: Piotr Poniedziałek <[email protected]>
pondzix added a commit that referenced this pull request Nov 6, 2024
Refactors the HTTP target to handle batches of data in one go, adds the ability to provide a template to get those batches of data into a request body, and adds a helper function to cover the case where there is no template provided.

This involves breaking changes - the previous behaviour can be achieved by configuring a template if the data is already JSON, or a transformation + a template if not - but we don't believe there are any use cases requiring us to do so.

- Refactors the http target to handle batches
- Adds configuration of batch sizes for http target
- Adds a templater function
- Adds a helper function which creates a JSON array from the data where no template is provided
- Adds a function to group data by dynamic headers where that is configured - to ensure that this feature still works
- Adds tests for these features

These features also introduce a new possibility for failure in the HTTP target. The http target now expects valid JSON (previously it could be anything) - where we hit an error in either templating this data - or in the case of no template in transforming the data into a JSON array request body - these messages are treated as invalid, and will be sent to the failure target.

---------

Co-authored-by: Piotr Poniedziałek <[email protected]>
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