Skip to content

Commit ba4c1ea

Browse files
authored
Merge pull request #305 from tinybirdco/iterate_api_endpoint_103
update readme
2 parents cc6c91e + 69d053c commit ba4c1ea

File tree

1 file changed

+14
-50
lines changed

1 file changed

+14
-50
lines changed

iterating_api_endpoint/README.md

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,22 @@ Modifying an endpoint is an easy and straightforward process, but you need to ke
44

55
> Remember to follow the [instructions](../README.md) to setup your Tinybird Data Project before diving into the use-case steps
66
7-
[Pull Request](https://github.com/tinybirdco/use-case-examples/pull/201/files)
7+
1. Breaking change
88

9-
In this example, we have an endpoint `top_browsers.pipe` that groups website visits by browser to identify the most frequently used ones. We want to modify it to group the information by both browser and device.
9+
[Pull Request](https://github.com/tinybirdco/use-case-examples/pull/304/files)
1010

11-
- Change the endpoint `pipes/top_browsers.pipe`:
12-
13-
```diff
14-
@@ -15,6 +15,7 @@ SQL >
15-
%
16-
select
17-
browser,
18-
+ device,
19-
uniqMerge(visits) as visits,
20-
countMerge(hits) as hits
21-
from
22-
@@ -31,7 +32,7 @@ SQL >
23-
and date <= today()
24-
{% end %}
25-
group by
26-
- browser
27-
+ browser, device
28-
order by
29-
visits desc
30-
limit {{Int32(skip, 0)}},{{Int32(limit, 50)}}
31-
```
11+
In this example, we have an endpoint `top_browsers.pipe` that groups website visits by browser to identify the most frequently used ones. We want to modify it to group the information by both browser and device, that is, changing the API contract.
3212

13+
- Create a new endpoint `pipes/top_browsers_1.pipe`:
3314
- (Optional) Add tests to the project to ensure that endpoint works as expected.
3415

35-
`tests/top_browser_default.test`:
16+
`tests/top_browser_1_default.test`:
3617

3718
```bash
38-
tb pipe data top_browsers --date_from 2024-01-11 --date_to 2024-01-12 --format CSV
19+
tb pipe data top_browsers1 --date_from 2024-01-11 --date_to 2024-01-12 --format CSV
3920
```
4021

41-
`tests/top_browser_default.test.result`:
22+
`tests/top_browser_1_default.test.result`:
4223

4324
```
4425
"browser","device","visits","hits"
@@ -47,31 +28,14 @@ tb pipe data top_browsers --date_from 2024-01-11 --date_to 2024-01-12 --format C
4728
"chrome","mobile-android",1,1
4829
```
4930

50-
- Add the flag `--skip-regression-tests` to your PR. This is required because Tinybird performs some automatic regression tests based on the endpoint's query log history. As we have changed the response of the endpoint, these automatic tests would fail. ([learn more about testing](https://versions.tinybird.co/docs/version-control/implementing-test-strategies.html)).
51-
52-
- As it is a **breaking change** let's deploy changes to a `Preview` release. This way we have both versions available in Tinybird. In this case we increase the major version, bump the semver version in `.tinyenv`.
53-
54-
`.tinyenv`:
55-
```diff
56-
- 0.0.0
57-
+ 1.0.0
58-
```
59-
60-
- Create a Pull Request with these changes and, once all the checks are satisfied, merge it. Then the `Preview` release will be created with the endpoint changes. From this moment, you can start to migrate all the API consumers to use the new version `1.0.0`. Just add `__tb__semver=1.0.0` to the url. Once `0.0.0` can be securely deprecated, promote `preview` to `live` following one of the next options:
61-
62-
- The action `Tinybird - Releases Workflow` in the case you are using our workflow templates.
63-
- Promote from the UI.
64-
- Or CLI:
65-
66-
```sh
67-
tb release promote --semver 1.0.0
68-
```
69-
70-
- Then you can get rid of `__tb__semver=1.0.0` on your service to be ready for next not breaking changes.
71-
72-
- In this case Tinybird rollback is available but not useful as your API consumer is not compatible wit both versions.
31+
- As it is a **breaking change** you keep the old and new version so any client application can start using the new version or rollback to the previous one.
7332

33+
2. Non-breaking change
7434

75-
> In case we are iterating **not a breaking change** the way to go is just to Deploy to a `Live` release (bumping minor or patch in `.tinyenv`). API consumer does not require any change and Tinybird rollback is available.
35+
[Pull Request](https://github.com/tinybirdco/use-case-examples/pull/302/files)
7636

37+
In this example we'll add a new filter to the `top_browser.pipe` Pipe endpoint, without changing the API contract, that is a non-breaking change.
7738

39+
- Change the endpoint `pipes/top_browsers.pipe`
40+
- (Optional) Add tests to the project, as described above, to ensure that endpoint works as expected
41+
- Add the flag `--skip-regression-tests` to your PR. This is required because Tinybird performs some automatic regression tests based on the endpoint's query log history. As we have changed the response of the endpoint, these automatic tests would fail. ([learn more about testing](https://versions.tinybird.co/docs/production/implementing-test-strategies.html)).

0 commit comments

Comments
 (0)