Skip to content

Commit 04d6466

Browse files
committed
remove ClientOptions and all dependencies
1 parent ff710d6 commit 04d6466

File tree

8 files changed

+94
-48
lines changed

8 files changed

+94
-48
lines changed

eventsourcingdb/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from .client import Client as EsdbClient
2-
from .client_options import ClientOptions as EsdbClientOptions

eventsourcingdb/client.py

Lines changed: 92 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from collections.abc import AsyncGenerator
22

33
from .client_configuration import ClientConfiguration
4-
from .client_options import ClientOptions
54
from .event.event_candidate import EventCandidate
65
from .event.event_context import EventContext
76
from .handlers.observe_events.observe_events import observe_events
@@ -27,66 +26,131 @@ def __init__(
2726
self,
2827
base_url: str,
2928
api_token: str,
30-
options: ClientOptions = ClientOptions()
3129
):
3230
configuration = ClientConfiguration(
3331
base_url=base_url,
34-
timeout_seconds=options.timeout_seconds,
3532
api_token=api_token,
36-
protocol_version=options.protocol_version,
37-
max_tries=options.max_tries
3833
)
3934

4035
self.__http_client = HttpClient(configuration)
4136

37+
#TODO: is this necessary? __enter__, __exit__
4238
async def initialize(self) -> None:
4339
await self.__http_client.initialize()
4440

41+
#TODO: is this necessary? magic method __enter__, __exit__
4542
async def close(self) -> None:
4643
await self.__http_client.close()
4744

4845
@property
4946
def http_client(self) -> HttpClient:
5047
return self.__http_client
5148

49+
# TODO: should we mix object orientation and functional programming?
5250
async def ping(self) -> None:
53-
return await ping(self)
54-
55-
async def read_subjects(
51+
return await ping(client=self)
52+
53+
async def verify_api_token(self) -> None:
54+
...
55+
56+
async def write_events(
5657
self,
57-
base_subject: str
58-
) -> AsyncGenerator[str, None]:
59-
async for subject in read_subjects(self, base_subject):
60-
yield subject
61-
58+
event_candidates: list[EventCandidate],
59+
preconditions: list[Precondition] = None
60+
) -> list[EventContext]: # TODO: list[Event] of Events (complete)
61+
if preconditions is None:
62+
preconditions = []
63+
return await write_events(self, event_candidates, preconditions)
64+
6265
async def read_events(
6366
self,
6467
subject: str,
6568
options: ReadEventsOptions
66-
) -> AsyncGenerator[StoreItem, None]:
69+
) -> AsyncGenerator[StoreItem, None]: # no StoreItem ... it is a Event
70+
#TODO: This is a code snippet for abort read events.
71+
"""
72+
https://github.com/thenativeweb/eventsourcingdb-client-javascript/blob/main/src/Client.ts#L134-L152
73+
for await (const event of client.readEvents('/', { recursive: true })) {
74+
console.log(event);
75+
76+
if (event.ID === '100') {
77+
break;
78+
}
79+
}
80+
81+
82+
function handlePostRequest(abortController) {
83+
const signal = abortController.signal;
84+
85+
for await (const event of client.readEvents('/', { recursive: true }), signal) {
86+
console.log(event);
87+
}
88+
89+
return http.status(200);
90+
}
91+
"""
6792
async for event in read_events(self, subject, options):
6893
yield event
6994

70-
async def read_event_types(self) -> AsyncGenerator[EventType, None]:
71-
async for event_type in read_event_types(self):
72-
yield event_type
73-
74-
async def register_event_schema(self, event_type: str, json_schema: str) -> None:
75-
await register_event_schema(self, event_type, json_schema)
95+
# TODO: run eventql query
96+
async def run_eventql_query(self, query: str) -> AsyncGenerator[Event, None]:
97+
"""
98+
the issue like read_events. can be abort or canceled.
99+
"""
76100

77101
async def observe_events(
78102
self,
79103
subject: str,
80104
options: ObserveEventsOptions
81-
) -> AsyncGenerator[StoreItem, None]:
105+
) -> AsyncGenerator[StoreItem, None]: # no StoreItem ... it is a Event
106+
"""
107+
TODO: the same issue like read_events. contextmanager
108+
"""
82109
async for event in observe_events(self, subject, options):
83110
yield event
84111

85-
async def write_events(
112+
async def register_event_schema(self, event_type: str, json_schema: str) -> None: # TODO: no json_schema is dict no string anymore
113+
# no context manager liek read_events
114+
await register_event_schema(self, event_type, json_schema)
115+
116+
async def read_subjects(
86117
self,
87-
event_candidates: list[EventCandidate],
88-
preconditions: list[Precondition] = None
89-
) -> list[EventContext]:
90-
if preconditions is None:
91-
preconditions = []
92-
return await write_events(self, event_candidates, preconditions)
118+
base_subject: str
119+
) -> AsyncGenerator[str, None]:
120+
# TODO: the same issue like read_events. contextmanager
121+
async for subject in read_subjects(self, base_subject):
122+
yield subject
123+
124+
125+
async def read_event_types(self) -> AsyncGenerator[EventType, None]:
126+
# TODO: the same issue like read_events. contextmanager
127+
async for event_type in read_event_types(self):
128+
yield event_type
129+
130+
131+
132+
""" TODO:
133+
134+
f (response.status !== 200) {
135+
throw new Error(
136+
`Failed to read event types, got HTTP status code '${response.status}', expected '200'.`,
137+
);
138+
}
139+
140+
"""
141+
142+
"""
143+
144+
A: Ausdüngen und Exception
145+
146+
B: Contextmanager
147+
148+
C: Neue Methoden
149+
150+
D: Testcontainer: testcontainers.com Python "virtuelle Container für tests"
151+
- EventSourcingDB(DockerContainer):
152+
def __init__(self):
153+
https://github.com/thenativeweb/eventsourcingdb-client-javascript/blob/main/src/EventSourcingDbContainer.ts
154+
"""
155+
156+
Dokumentationslink für Featurecheck: https://docs.eventsourcingdb.io/client-sdks/compliance-criteria/#detailed-requirements

eventsourcingdb/client_configuration.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44
@dataclass
55
class ClientConfiguration:
66
base_url: str
7-
timeout_seconds: int
87
api_token: str
9-
protocol_version: str
10-
max_tries: int

eventsourcingdb/client_options.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[project]
66
name = "eventsourcingdb"
7-
version = "0.11.0"
7+
version = "0.10.1"
88
description = "The official Python client SDK for EventSourcingDB."
99
authors = [
1010
{ name = "the native web GmbH", email = "[email protected]" }

tests/shared/containerized_testing_database.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from eventsourcingdb.client import Client
2-
from eventsourcingdb.client_options import ClientOptions
32

43
from .docker.container import Container
54
from .docker.image import Image
@@ -27,13 +26,12 @@ async def create(
2726
image: Image,
2827
command: [str],
2928
api_token: str,
30-
options: ClientOptions = ClientOptions(),
3129
) -> 'ContainerizedTestingDatabase':
3230
command.extend(['--http-enabled', '--https-enabled=false'])
3331
container = image.run(command, True, True)
3432
exposed_port = container.get_exposed_port(3_000)
3533
base_url = f'http://127.0.0.1:{exposed_port}'
36-
client = Client(base_url, api_token=api_token, options=options)
34+
client = Client(base_url, api_token=api_token)
3735
await client.initialize()
3836

3937
await client.ping()

tests/shared/database.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import uuid
22

33
from eventsourcingdb.client import Client
4-
from eventsourcingdb.client_options import ClientOptions
54

65
from .containerized_testing_database import ContainerizedTestingDatabase
76
from .docker.image import Image
@@ -32,7 +31,6 @@ async def create(cls) -> 'Database':
3231
image,
3332
['run', '--api-token', f'{api_token}', '--data-directory-temporary'],
3433
api_token,
35-
ClientOptions()
3634
)
3735

3836
with_invalid_url_client = Client(

tests/shared/start_local_http_server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from flask import Flask, Response, make_response
77

88
from eventsourcingdb.client import Client
9-
from eventsourcingdb.client_options import ClientOptions
109
from eventsourcingdb.util.retry.retry_with_backoff import retry_with_backoff
1110
from eventsourcingdb.util.retry.retry_result import Retry, Return, RetryResult
1211

@@ -77,7 +76,6 @@ def stop_server():
7776
client = Client(
7877
f'http://localhost:{local_http_server.port}',
7978
'access-token',
80-
ClientOptions(max_tries=3) # Increase max_tries from 2 to 3
8179
)
8280
await client.initialize()
8381

0 commit comments

Comments
 (0)