s2-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. s2_sdk-0.1.0/.github/workflows/ci.yml +77 -0
  2. s2_sdk-0.1.0/.github/workflows/pr-title.yml +34 -0
  3. s2_sdk-0.1.0/.github/workflows/release-please.yml +29 -0
  4. s2_sdk-0.1.0/.github/workflows/release.yml +21 -0
  5. s2_sdk-0.1.0/.gitignore +16 -0
  6. s2_sdk-0.1.0/.gitmodules +3 -0
  7. s2_sdk-0.1.0/.python-version +1 -0
  8. s2_sdk-0.1.0/.readthedocs.yaml +20 -0
  9. s2_sdk-0.1.0/.release-please-manifest.json +3 -0
  10. s2_sdk-0.1.0/CHANGELOG.md +8 -0
  11. s2_sdk-0.1.0/CODEOWNERS +1 -0
  12. s2_sdk-0.1.0/LICENSE +21 -0
  13. s2_sdk-0.1.0/PKG-INFO +52 -0
  14. s2_sdk-0.1.0/README.md +40 -0
  15. s2_sdk-0.1.0/docs/Makefile +20 -0
  16. s2_sdk-0.1.0/docs/make.bat +35 -0
  17. s2_sdk-0.1.0/docs/source/_static/s2-logo-black.png +0 -0
  18. s2_sdk-0.1.0/docs/source/_static/s2-logo-white.png +0 -0
  19. s2_sdk-0.1.0/docs/source/api-reference.md +183 -0
  20. s2_sdk-0.1.0/docs/source/conf.py +46 -0
  21. s2_sdk-0.1.0/docs/source/index.md +8 -0
  22. s2_sdk-0.1.0/examples/consumer.py +37 -0
  23. s2_sdk-0.1.0/examples/producer.py +44 -0
  24. s2_sdk-0.1.0/pyproject.toml +77 -0
  25. s2_sdk-0.1.0/pytest.ini +20 -0
  26. s2_sdk-0.1.0/release-please-config.json +14 -0
  27. s2_sdk-0.1.0/s2-specs/.github/workflows/dispatch.yaml +32 -0
  28. s2_sdk-0.1.0/s2-specs/README.md +9 -0
  29. s2_sdk-0.1.0/s2-specs/buf.yaml +15 -0
  30. s2_sdk-0.1.0/s2-specs/s2/v1/openapi.json +3277 -0
  31. s2_sdk-0.1.0/s2-specs/s2/v1/s2.proto +81 -0
  32. s2_sdk-0.1.0/s2-specs/s2/v1/s2s.md +26 -0
  33. s2_sdk-0.1.0/s2-specs/s2/v1alpha/s2.proto +734 -0
  34. s2_sdk-0.1.0/src/s2_sdk/__init__.py +129 -0
  35. s2_sdk-0.1.0/src/s2_sdk/_append_session.py +216 -0
  36. s2_sdk-0.1.0/src/s2_sdk/_batching.py +105 -0
  37. s2_sdk-0.1.0/src/s2_sdk/_client.py +1088 -0
  38. s2_sdk-0.1.0/src/s2_sdk/_compression.py +32 -0
  39. s2_sdk-0.1.0/src/s2_sdk/_exceptions.py +194 -0
  40. s2_sdk-0.1.0/src/s2_sdk/_frame_signal.py +21 -0
  41. s2_sdk-0.1.0/src/s2_sdk/_generated/__init__.py +0 -0
  42. s2_sdk-0.1.0/src/s2_sdk/_generated/s2/__init__.py +0 -0
  43. s2_sdk-0.1.0/src/s2_sdk/_generated/s2/v1/__init__.py +0 -0
  44. s2_sdk-0.1.0/src/s2_sdk/_generated/s2/v1/s2_pb2.py +46 -0
  45. s2_sdk-0.1.0/src/s2_sdk/_generated/s2/v1/s2_pb2.pyi +106 -0
  46. s2_sdk-0.1.0/src/s2_sdk/_mappers.py +401 -0
  47. s2_sdk-0.1.0/src/s2_sdk/_ops.py +1069 -0
  48. s2_sdk-0.1.0/src/s2_sdk/_producer.py +219 -0
  49. s2_sdk-0.1.0/src/s2_sdk/_retrier.py +131 -0
  50. s2_sdk-0.1.0/src/s2_sdk/_s2s/__init__.py +5 -0
  51. s2_sdk-0.1.0/src/s2_sdk/_s2s/_append_session.py +224 -0
  52. s2_sdk-0.1.0/src/s2_sdk/_s2s/_protocol.py +189 -0
  53. s2_sdk-0.1.0/src/s2_sdk/_s2s/_read_session.py +153 -0
  54. s2_sdk-0.1.0/src/s2_sdk/_types.py +613 -0
  55. s2_sdk-0.1.0/src/s2_sdk/_validators.py +53 -0
  56. s2_sdk-0.1.0/src/s2_sdk/py.typed +0 -0
  57. s2_sdk-0.1.0/tests/__init__.py +0 -0
  58. s2_sdk-0.1.0/tests/conftest.py +125 -0
  59. s2_sdk-0.1.0/tests/test_account_ops.py +293 -0
  60. s2_sdk-0.1.0/tests/test_basin_ops.py +546 -0
  61. s2_sdk-0.1.0/tests/test_batching.py +74 -0
  62. s2_sdk-0.1.0/tests/test_client.py +677 -0
  63. s2_sdk-0.1.0/tests/test_compression.py +33 -0
  64. s2_sdk-0.1.0/tests/test_metrics_ops.py +192 -0
  65. s2_sdk-0.1.0/tests/test_producer.py +335 -0
  66. s2_sdk-0.1.0/tests/test_retry.py +145 -0
  67. s2_sdk-0.1.0/tests/test_s2s_protocol.py +86 -0
  68. s2_sdk-0.1.0/tests/test_session.py +723 -0
  69. s2_sdk-0.1.0/tests/test_stream_ops.py +846 -0
  70. s2_sdk-0.1.0/tests/test_validators.py +27 -0
  71. s2_sdk-0.1.0/update_specs +17 -0
  72. s2_sdk-0.1.0/uv.lock +1468 -0
@@ -0,0 +1,77 @@
1
+ name: CI
2
+
3
+ # NOTE: keep UV_VERSION in sync with uv-version in s2-lite-integration-tests sdks JSON below.
4
+ env:
5
+ UV_VERSION: "0.11.3"
6
+
7
+ on:
8
+ pull_request:
9
+ types:
10
+ [
11
+ opened,
12
+ synchronize,
13
+ ready_for_review,
14
+ reopened,
15
+ ]
16
+ jobs:
17
+ local-checks:
18
+ name: Local Checks (code quality, unit tests, docs build)
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - name: Checkout repository
22
+ uses: actions/checkout@v4
23
+ - name: Install uv
24
+ uses: astral-sh/setup-uv@v7
25
+ with:
26
+ version: ${{ env.UV_VERSION }}
27
+ - name: Sync dependencies
28
+ run: |
29
+ uv sync --all-groups
30
+ - name: Static code check
31
+ run: uv run poe ci_checker
32
+ - name: Unit tests
33
+ run: uv run pytest tests/ -v -m 'not (account or basin or stream or metrics)'
34
+ - name: Check docs build
35
+ working-directory: ./docs
36
+ run: |
37
+ make html
38
+ s2-cloud-integration-tests:
39
+ name: s2-cloud integration tests
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - name: Checkout repository
43
+ uses: actions/checkout@v4
44
+ - name: Install uv
45
+ uses: astral-sh/setup-uv@v7
46
+ with:
47
+ version: ${{ env.UV_VERSION }}
48
+ - name: Sync dependencies
49
+ run: uv sync --group test
50
+ - name: Run integration tests
51
+ env:
52
+ S2_ACCESS_TOKEN: ${{ secrets.S2_ACCESS_TOKEN }}
53
+ run: uv run pytest tests/ -v -s -m 'account or basin or stream or metrics'
54
+
55
+ build-s2-lite:
56
+ name: Build s2-lite
57
+ uses: s2-streamstore/s2/.github/workflows/build-s2-lite.yml@main
58
+
59
+ s2-lite-integration-tests:
60
+ name: s2-lite integration tests
61
+ needs: build-s2-lite
62
+ uses: s2-streamstore/s2/.github/workflows/sdk-tests.yml@main
63
+ with:
64
+ server-binary: server
65
+ server-args: "--port 8080"
66
+ server-port: 8080
67
+ sdks: |
68
+ [
69
+ {
70
+ "name": "python",
71
+ "repo": "${{ github.repository }}",
72
+ "ref": "${{ github.ref }}",
73
+ "lang": "python",
74
+ "uv-version": "0.11.3",
75
+ "test_cmd": "uv run pytest tests/ -v -s -m '(account or basin or stream) and not cloud_only'"
76
+ }
77
+ ]
@@ -0,0 +1,34 @@
1
+ name: PR Title
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, edited, synchronize, reopened]
6
+
7
+ permissions:
8
+ pull-requests: read
9
+
10
+ jobs:
11
+ validate:
12
+ name: Validate PR Title
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: amannn/action-semantic-pull-request@v5
16
+ env:
17
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18
+ with:
19
+ types: |
20
+ feat
21
+ fix
22
+ docs
23
+ perf
24
+ refactor
25
+ style
26
+ test
27
+ chore
28
+ ci
29
+ revert
30
+ requireScope: false
31
+ subjectPattern: ^.+$
32
+ subjectPatternError: |
33
+ The subject "{subject}" is not valid.
34
+ Please use a non-empty subject after the type/scope.
@@ -0,0 +1,29 @@
1
+ name: Release Please
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: write
10
+ pull-requests: write
11
+
12
+ jobs:
13
+ release-please:
14
+ runs-on: ubuntu-latest
15
+ outputs:
16
+ release_created: ${{ steps.release.outputs.release_created }}
17
+ tag_name: ${{ steps.release.outputs.tag_name }}
18
+ steps:
19
+ - uses: actions/create-github-app-token@v1
20
+ id: app-token
21
+ with:
22
+ app-id: ${{ secrets.RELEASE_PLZ_APP_ID }}
23
+ private-key: ${{ secrets.RELEASE_PLZ_APP_PRIVATE_KEY }}
24
+ - uses: googleapis/release-please-action@v4
25
+ id: release
26
+ with:
27
+ config-file: release-please-config.json
28
+ manifest-file: .release-please-manifest.json
29
+ token: ${{ steps.app-token.outputs.token }}
@@ -0,0 +1,21 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
6
+
7
+ jobs:
8
+ pypi-publish:
9
+ name: Build and publish to PyPI
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v4
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v7
18
+ - name: Build package
19
+ run: uv build
20
+ - name: Publish package to PyPI
21
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,16 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Sphinx
13
+ docs/build
14
+
15
+ # Claude Code
16
+ .claude/
@@ -0,0 +1,3 @@
1
+ [submodule "s2-specs"]
2
+ path = s2-specs
3
+ url = https://github.com/s2-streamstore/s2-specs.git
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,20 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ version: 2
5
+
6
+ build:
7
+ os: ubuntu-24.04
8
+ tools:
9
+ python: "3.11"
10
+ jobs:
11
+ create_environment:
12
+ - asdf plugin add uv
13
+ - asdf install uv 0.8.2
14
+ - asdf global uv 0.8.2
15
+ - UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --group docs
16
+ install:
17
+ - "true"
18
+
19
+ sphinx:
20
+ configuration: docs/source/conf.py
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.1.0"
3
+ }
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-04-07)
4
+
5
+
6
+ ### Features
7
+
8
+ * add initial version of `s2-sdk` ([#1](https://github.com/s2-streamstore/s2-sdk-python/issues/1)) ([3dc9795](https://github.com/s2-streamstore/s2-sdk-python/commit/3dc979596b10db0881dd3132165467a227ad79d3))
@@ -0,0 +1 @@
1
+ * @s2-streamstore/dev
s2_sdk-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bandar Systems Inc. and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
s2_sdk-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.4
2
+ Name: s2-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for s2.dev
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: h2>=4.1.0
9
+ Requires-Dist: protobuf>=5.29.0
10
+ Requires-Dist: zstandard>=0.23.0
11
+ Description-Content-Type: text/markdown
12
+
13
+ # s2-sdk
14
+ <div>
15
+ <p>
16
+ <!-- PyPI -->
17
+ <a href="https://pypi.org/project/s2-sdk/"><img src="https://img.shields.io/pypi/v/s2-sdk" /></a>
18
+ <!-- Read the docs -->
19
+ <a href="https://s2-sdk.readthedocs.io/"><img src="https://img.shields.io/readthedocs/s2-sdk/latest" /></a>
20
+ <!-- Discord -->
21
+ <a href="https://discord.gg/vTCs7kMkAf"><img src="https://img.shields.io/discord/1209937852528599092?logo=discord" /></a>
22
+ <!-- LICENSE -->
23
+ <a href="https://github.com/s2-streamstore/s2-sdk-python/blob/main/LICENSE"><img src="https://img.shields.io/github/license/s2-streamstore/s2-sdk-python" /></a>
24
+ </p>
25
+ </div>
26
+
27
+ `s2-sdk` is the Python SDK for [S2](https://s2.dev/).
28
+
29
+ ## Project links
30
+
31
+ - [PyPI](https://pypi.org/project/s2-sdk/)
32
+ - [Documentation](https://s2-sdk.readthedocs.io/)
33
+ - [GitHub](https://github.com/s2-streamstore/s2-sdk-python)
34
+
35
+ ## Requirements
36
+
37
+ Python >= 3.11
38
+
39
+ ## Installation
40
+
41
+ You can install the package from the [Python Package Index](https://pypi.org/project/s2-sdk) using the package manager of your choice. E.g., with `pip`:
42
+
43
+ ```bash
44
+ pip install s2-sdk
45
+ ```
46
+
47
+ ## Get in touch
48
+
49
+ Join our [Discord](https://discord.gg/vTCs7kMkAf) server. We would love to hear
50
+ from you.
51
+
52
+ You can also email us at [hi@s2.dev](mailto:hi@s2.dev).
s2_sdk-0.1.0/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # s2-sdk
2
+ <div>
3
+ <p>
4
+ <!-- PyPI -->
5
+ <a href="https://pypi.org/project/s2-sdk/"><img src="https://img.shields.io/pypi/v/s2-sdk" /></a>
6
+ <!-- Read the docs -->
7
+ <a href="https://s2-sdk.readthedocs.io/"><img src="https://img.shields.io/readthedocs/s2-sdk/latest" /></a>
8
+ <!-- Discord -->
9
+ <a href="https://discord.gg/vTCs7kMkAf"><img src="https://img.shields.io/discord/1209937852528599092?logo=discord" /></a>
10
+ <!-- LICENSE -->
11
+ <a href="https://github.com/s2-streamstore/s2-sdk-python/blob/main/LICENSE"><img src="https://img.shields.io/github/license/s2-streamstore/s2-sdk-python" /></a>
12
+ </p>
13
+ </div>
14
+
15
+ `s2-sdk` is the Python SDK for [S2](https://s2.dev/).
16
+
17
+ ## Project links
18
+
19
+ - [PyPI](https://pypi.org/project/s2-sdk/)
20
+ - [Documentation](https://s2-sdk.readthedocs.io/)
21
+ - [GitHub](https://github.com/s2-streamstore/s2-sdk-python)
22
+
23
+ ## Requirements
24
+
25
+ Python >= 3.11
26
+
27
+ ## Installation
28
+
29
+ You can install the package from the [Python Package Index](https://pypi.org/project/s2-sdk) using the package manager of your choice. E.g., with `pip`:
30
+
31
+ ```bash
32
+ pip install s2-sdk
33
+ ```
34
+
35
+ ## Get in touch
36
+
37
+ Join our [Discord](https://discord.gg/vTCs7kMkAf) server. We would love to hear
38
+ from you.
39
+
40
+ You can also email us at [hi@s2.dev](mailto:hi@s2.dev).
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= uv run sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -0,0 +1,183 @@
1
+ # API Reference
2
+
3
+ ```{eval-rst}
4
+ .. module:: s2_sdk
5
+
6
+ .. autoclass:: S2
7
+ :members:
8
+
9
+
10
+ .. autoclass:: S2Basin()
11
+ :members:
12
+
13
+
14
+ .. autoclass:: S2Stream()
15
+ :members:
16
+
17
+
18
+ .. autoclass:: AppendSession()
19
+ :members:
20
+
21
+
22
+ .. autoclass:: BatchSubmitTicket()
23
+ :members:
24
+
25
+ .. autoclass:: Producer()
26
+ :members:
27
+
28
+
29
+ .. autoclass:: RecordSubmitTicket()
30
+ :members:
31
+
32
+ .. autoclass:: Endpoints
33
+ :members:
34
+
35
+
36
+ .. autoclass:: Timeout(request: timedelta = timedelta(seconds=5), connection: timedelta = timedelta(seconds=3))
37
+ :members:
38
+
39
+ .. autoclass:: Retry(max_attempts: int = 3, min_base_delay: timedelta = timedelta(milliseconds=100), max_base_delay: timedelta = timedelta(seconds=1), append_retry_policy: AppendRetryPolicy = AppendRetryPolicy.ALL)
40
+ :members:
41
+
42
+ .. autoclass:: Batching(max_records: int = 1000, max_bytes: int = 1048576, linger: timedelta = timedelta(milliseconds=5))
43
+ :members:
44
+
45
+ .. autoclass:: Record(body: bytes, headers: list[tuple[bytes, bytes]] = [], timestamp: int | None = None)
46
+ :members:
47
+
48
+ .. autoclass:: AppendInput
49
+ :members:
50
+
51
+ .. autoclass:: AppendAck()
52
+ :members:
53
+
54
+ .. autoclass:: IndexedAppendAck()
55
+ :members:
56
+
57
+ .. autoclass:: StreamPosition()
58
+ :members:
59
+
60
+ .. autoclass:: ReadLimit
61
+ :members:
62
+
63
+ .. autoclass:: ReadBatch()
64
+ :members:
65
+
66
+ .. autoclass:: SequencedRecord()
67
+ :members:
68
+
69
+ .. autoclass:: SeqNum
70
+ :members:
71
+
72
+ .. autoclass:: Timestamp
73
+ :members:
74
+
75
+ .. autoclass:: TailOffset
76
+ :members:
77
+
78
+ .. autoclass:: Page()
79
+ :members:
80
+
81
+ .. autoclass:: CommandRecord()
82
+ :members:
83
+
84
+
85
+ .. autofunction:: metered_bytes
86
+
87
+ .. autofunction:: append_record_batches
88
+
89
+ .. autofunction:: append_inputs
90
+
91
+ .. autoenum:: Compression
92
+
93
+ .. autoenum:: AppendRetryPolicy
94
+
95
+ .. autoenum:: StorageClass
96
+
97
+ .. autoenum:: TimestampingMode
98
+
99
+ .. autoclass:: Timestamping
100
+ :members:
101
+
102
+ .. autoclass:: StreamConfig
103
+ :members:
104
+
105
+ .. autoclass:: BasinConfig
106
+ :members:
107
+
108
+ .. autoenum:: BasinScope
109
+
110
+ .. autoclass:: BasinInfo()
111
+ :members:
112
+
113
+ .. autoclass:: StreamInfo()
114
+ :members:
115
+
116
+ .. autoclass:: ExactMatch
117
+ :members:
118
+
119
+ .. autoclass:: PrefixMatch
120
+ :members:
121
+
122
+ .. autoenum:: Permission
123
+
124
+ .. autoenum:: Operation
125
+
126
+ .. autoclass:: OperationGroupPermissions
127
+ :members:
128
+
129
+ .. autoclass:: AccessTokenScope(basins: ExactMatch | PrefixMatch | None = None, streams: ExactMatch | PrefixMatch | None = None, access_tokens: ExactMatch | PrefixMatch | None = None, op_groups: OperationGroupPermissions | None = None, ops: list[Operation] = [])
130
+ :members:
131
+
132
+ .. autoclass:: AccessTokenInfo()
133
+ :members:
134
+
135
+ .. autoenum:: MetricUnit
136
+
137
+ .. autoenum:: TimeseriesInterval
138
+
139
+ .. autoenum:: AccountMetricSet
140
+
141
+ .. autoenum:: BasinMetricSet
142
+
143
+ .. autoenum:: StreamMetricSet
144
+
145
+ .. autoclass:: Scalar()
146
+ :members:
147
+
148
+ .. autoclass:: Accumulation()
149
+ :members:
150
+
151
+ .. autoclass:: Gauge()
152
+ :members:
153
+
154
+ .. autoclass:: Label()
155
+ :members:
156
+
157
+ .. autoclass:: S2Error()
158
+ :members:
159
+
160
+ .. autoclass:: S2ClientError()
161
+ :members:
162
+ :show-inheritance:
163
+
164
+ .. autoclass:: S2ServerError()
165
+ :members:
166
+ :show-inheritance:
167
+
168
+ .. autoclass:: AppendConditionError()
169
+ :members:
170
+ :show-inheritance:
171
+
172
+ .. autoclass:: FencingTokenMismatchError()
173
+ :members:
174
+ :show-inheritance:
175
+
176
+ .. autoclass:: SeqNumMismatchError()
177
+ :members:
178
+ :show-inheritance:
179
+
180
+ .. autoclass:: ReadUnwrittenError()
181
+ :members:
182
+ :show-inheritance:
183
+ ```
@@ -0,0 +1,46 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+
9
+ from datetime import date
10
+
11
+ project = "s2-sdk"
12
+ copyright = f"{date.today().year}, Bandar Systems Inc"
13
+ release = "0.1.0" # x-release-please-version
14
+
15
+ # -- General configuration ---------------------------------------------------
16
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
17
+
18
+ extensions = [
19
+ "myst_parser",
20
+ "sphinx.ext.napoleon",
21
+ "sphinx.ext.autodoc",
22
+ "sphinx.ext.autodoc.typehints",
23
+ "sphinx.ext.intersphinx",
24
+ "enum_tools.autoenum",
25
+ "sphinx.ext.viewcode",
26
+ ]
27
+
28
+ templates_path = ["_templates"]
29
+ exclude_patterns = []
30
+
31
+
32
+ autodoc_member_order = "bysource"
33
+ autodoc_typehints_format = "short"
34
+ python_use_unqualified_type_names = True
35
+
36
+ intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
37
+
38
+ # -- Options for HTML output -------------------------------------------------
39
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
40
+
41
+ html_theme = "furo"
42
+ html_static_path = ["_static"]
43
+ html_theme_options = {
44
+ "light_logo": "s2-logo-black.png",
45
+ "dark_logo": "s2-logo-white.png",
46
+ }
@@ -0,0 +1,8 @@
1
+ ```{include} ../../README.md
2
+ ```
3
+
4
+ ```{toctree}
5
+ :hidden:
6
+
7
+ api-reference
8
+ ```
@@ -0,0 +1,37 @@
1
+ import asyncio
2
+ import logging
3
+ import os
4
+
5
+ from s2_sdk import S2, Endpoints, SeqNum
6
+
7
+ logging.basicConfig(level=logging.INFO)
8
+ logging.getLogger("s2_sdk").setLevel(
9
+ getattr(logging, os.getenv("S2_LOG_LEVEL", "INFO").upper(), logging.INFO)
10
+ )
11
+ logger = logging.getLogger(__name__)
12
+
13
+ ACCESS_TOKEN = os.environ["S2_ACCESS_TOKEN"]
14
+ BASIN = os.environ["S2_BASIN"]
15
+ STREAM = os.environ["S2_STREAM"]
16
+ ACCOUNT_ENDPOINT = os.getenv("S2_ACCOUNT_ENDPOINT")
17
+ BASIN_ENDPOINT = os.getenv("S2_BASIN_ENDPOINT")
18
+
19
+
20
+ async def consumer():
21
+ endpoints = (
22
+ Endpoints(account=ACCOUNT_ENDPOINT, basin=BASIN_ENDPOINT)
23
+ if ACCOUNT_ENDPOINT and BASIN_ENDPOINT
24
+ else None
25
+ )
26
+ async with S2(ACCESS_TOKEN, endpoints=endpoints) as s2:
27
+ stream = s2[BASIN][STREAM]
28
+ tail = await stream.check_tail()
29
+ logger.info("reading from tail: %s", tail)
30
+ total_num_records = 0
31
+ async for batch in stream.read_session(start=SeqNum(tail.seq_num)):
32
+ total_num_records += len(batch.records)
33
+ logger.info("read %d now, %d so far", len(batch.records), total_num_records)
34
+
35
+
36
+ if __name__ == "__main__":
37
+ asyncio.run(consumer())