Skip to content

Commit

Permalink
Removed 'partition' arg.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbywater committed May 20, 2024
1 parent 0ecb278 commit c9ae0f1
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# SHELL = bash

# EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-ce/eventstoredb-ce:22.10.4-jammy
# EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-ce/eventstoredb-ce:23.10.0-jammy
EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-ce/eventstoredb-ce:23.10.0-jammy
# EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-ce/eventstoredb-ce:24.2.0-alpha.115-jammy
EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-staging-ce/eventstoredb-ce:24.6.0-nightly-x64-8.0-jammy
# EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-staging-ce/eventstoredb-ce:24.6.0-nightly-x64-8.0-jammy


POETRY ?= poetry
Expand Down
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2946,10 +2946,7 @@ The `get_projection_state()` method can be used to get a projection's "state".
This method has a required `name` argument, which is a Python `str` that
specifies the name of a projection.

This method also has three optional arguments, `partition`, `timeout`, and `credentials`.

The optional `partition` argument is a Python `str` which specifies a "partition". The
default value of `partition` is the empty string.
This method also has two optional arguments, `timeout` and `credentials`.

The optional `timeout` argument is a Python `float` which sets a
maximum duration, in seconds, for the completion of the gRPC operation.
Expand Down Expand Up @@ -2978,10 +2975,7 @@ A projection's "result" holds the same data as the projections "state".
This method has a required `name` argument, which is a Python `str` that
specifies the name of a projection.

This method also has three optional arguments, `partition`, `timeout`, and `credentials`.

The optional `partition` argument is a Python `str` which specifies a "partition". The
default value of `partition` is the empty string.
This method also has two optional arguments, `timeout` and `credentials`.

The optional `timeout` argument is a Python `float` which sets a
maximum duration, in seconds, for the completion of the gRPC operation.
Expand All @@ -3000,14 +2994,12 @@ assert projection_result.value == {'count': 3}

### Get projection statistics<a id="get-projection-statistics"></a>

The `get_projection_statistucs()` method can be used to get projection statistics.
The `get_projection_statistics()` method can be used to get projection statistics.

This method has a required `name` argument, which is a Python `str` that specifies the
name of a projection.

This method also has three optional arguments, `partition`, `timeout`, and `credentials`.

The optional `partition` argument is a Python `str` which specifies a partition.
This method also has two optional arguments, `timeout` and `credentials`.

The optional `timeout` argument is a Python `float` which sets a
maximum duration, in seconds, for the completion of the gRPC operation.
Expand Down
8 changes: 3 additions & 5 deletions esdbclient/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ async def get_projection_statistics(
"""
timeout = timeout if timeout is not None else self._default_deadline

return await self._connection.projections.get_projection_statistics(
return await self._connection.projections.get_statistics(
name=name,
timeout=timeout,
metadata=self._call_metadata,
Expand Down Expand Up @@ -1559,7 +1559,6 @@ async def get_projection_state(
self,
name: str,
*,
partition: str = "",
timeout: Optional[float] = None,
credentials: Optional[grpc.CallCredentials] = None,
) -> ProjectionState:
Expand All @@ -1570,7 +1569,7 @@ async def get_projection_state(

return await self._connection.projections.get_state(
name=name,
partition=partition,
partition="",
timeout=timeout,
metadata=self._call_metadata,
credentials=credentials or self._call_credentials,
Expand All @@ -1582,7 +1581,6 @@ async def get_projection_result(
self,
name: str,
*,
partition: str = "",
timeout: Optional[float] = None,
credentials: Optional[grpc.CallCredentials] = None,
) -> ProjectionResult:
Expand All @@ -1593,7 +1591,7 @@ async def get_projection_result(

return await self._connection.projections.get_result(
name=name,
partition=partition,
partition="",
timeout=timeout,
metadata=self._call_metadata,
credentials=credentials or self._call_credentials,
Expand Down
8 changes: 3 additions & 5 deletions esdbclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ def get_projection_statistics(
"""
timeout = timeout if timeout is not None else self._default_deadline

return self._esdb.projections.get_projection_statistics(
return self._esdb.projections.get_statistics(
name=name,
timeout=timeout,
metadata=self._call_metadata,
Expand Down Expand Up @@ -1759,7 +1759,6 @@ def get_projection_state(
self,
name: str,
*,
partition: str = "",
timeout: Optional[float] = None,
credentials: Optional[grpc.CallCredentials] = None,
) -> ProjectionState:
Expand All @@ -1770,7 +1769,7 @@ def get_projection_state(

return self._esdb.projections.get_state(
name=name,
partition=partition,
partition="",
timeout=timeout,
metadata=self._call_metadata,
credentials=credentials or self._call_credentials,
Expand All @@ -1782,7 +1781,6 @@ def get_projection_result(
self,
name: str,
*,
partition: str = "",
timeout: Optional[float] = None,
credentials: Optional[grpc.CallCredentials] = None,
) -> ProjectionResult:
Expand All @@ -1793,7 +1791,7 @@ def get_projection_result(

return self._esdb.projections.get_result(
name=name,
partition=partition,
partition="",
timeout=timeout,
metadata=self._call_metadata,
credentials=credentials or self._call_credentials,
Expand Down
4 changes: 2 additions & 2 deletions esdbclient/projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ async def delete(
raise handle_rpc_error(e) from None
assert isinstance(delete_resp, projections_pb2.DeleteResp)

async def get_projection_statistics(
async def get_statistics(
self,
name: str,
timeout: Optional[float] = None,
Expand Down Expand Up @@ -564,7 +564,7 @@ def delete(
raise handle_rpc_error(e) from None
assert isinstance(delete_resp, projections_pb2.DeleteResp)

def get_projection_statistics(
def get_statistics(
self,
name: str,
timeout: Optional[float] = None,
Expand Down
32 changes: 12 additions & 20 deletions tests/test_asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2682,17 +2682,15 @@ async def test_get_projection_state(self) -> None:

# Raises NotFound unless projection exists.
with self.assertRaises(NotFound):
await self.client.get_projection_state(name=projection_name, partition="")
await self.client.get_projection_state(name=projection_name)

# Create named projection (query is an empty string).
await self.client.create_projection(query="", name=projection_name)

# Try to get projection state.
# Todo: Why does this just hang?
with self.assertRaises(DeadlineExceeded):
await self.client.get_projection_state(
name=projection_name, partition="", timeout=1
)
await self.client.get_projection_state(name=projection_name, timeout=1)

# Create named projection.
projection_name = str(uuid4())
Expand All @@ -2702,27 +2700,23 @@ async def test_get_projection_state(self) -> None:
)

# Get projection state.
state = await self.client.get_projection_state(
name=projection_name, partition="", timeout=1
)
state = await self.client.get_projection_state(name=projection_name, timeout=1)
self.assertEqual(state.value, {})

async def test_get_projection_result(self) -> None:
projection_name = str(uuid4())

# Raises NotFound unless projection exists.
with self.assertRaises(NotFound):
await self.client.get_projection_result(name=projection_name, partition="")
await self.client.get_projection_result(name=projection_name)

# Create named projection.
await self.client.create_projection(query="", name=projection_name)

# Try to get projection result.
# Todo: Why does this just hang?
with self.assertRaises(DeadlineExceeded):
await self.client.get_projection_result(
name=projection_name, partition="", timeout=1
)
await self.client.get_projection_result(name=projection_name, timeout=1)

# Create named projection.
projection_name = str(uuid4())
Expand All @@ -2732,9 +2726,7 @@ async def test_get_projection_result(self) -> None:
)

# Get projection result.
state = await self.client.get_projection_result(
name=projection_name, partition=""
)
state = await self.client.get_projection_result(name=projection_name)
self.assertEqual(state.value, {})

async def test_restart_projections_subsystem(self) -> None:
Expand Down Expand Up @@ -2819,12 +2811,12 @@ async def test_projection_example(self) -> None:
self.fail("Timed out waiting for two events to be processed by projection")

# Check projection state.
state = await self.client.get_projection_state(projection_name, partition="")
state = await self.client.get_projection_state(name=projection_name)
self.assertEqual(2, state.value["count"])

# Check projection result.
# Todo: What's the actual difference between "state" and "result"?
result = await self.client.get_projection_result(projection_name, partition="")
result = await self.client.get_projection_result(name=projection_name)
self.assertEqual(2, result.value["count"])

# Check project result stream.
Expand Down Expand Up @@ -2857,7 +2849,7 @@ async def test_projection_example(self) -> None:
# Reset whilst running is ineffective (state exists).
await self.client.reset_projection(name=projection_name)
await asyncio.sleep(1)
state = await self.client.get_projection_state(projection_name, partition="")
state = await self.client.get_projection_state(name=projection_name)
self.assertIn("count", state.value)
statistics = await self.client.get_projection_statistics(name=projection_name)
self.assertEqual("Running", statistics.status)
Expand All @@ -2879,13 +2871,13 @@ async def test_projection_example(self) -> None:
self.assertEqual("Stopped", statistics.status)

# Check projection still has state.
state = await self.client.get_projection_state(projection_name, partition="")
state = await self.client.get_projection_state(projection_name)
self.assertIn("count", state.value)

# Reset whilst stopped is effective (loses state)?
await self.client.reset_projection(name=projection_name)
await asyncio.sleep(1)
state = await self.client.get_projection_state(projection_name, partition="")
state = await self.client.get_projection_state(projection_name)
self.assertNotIn("count", state.value)
statistics = await self.client.get_projection_statistics(name=projection_name)
self.assertEqual("Stopped", statistics.status)
Expand All @@ -2896,7 +2888,7 @@ async def test_projection_example(self) -> None:
await asyncio.sleep(1)
statistics = await self.client.get_projection_statistics(name=projection_name)
self.assertEqual("Running", statistics.status)
state = await self.client.get_projection_state(projection_name, partition="")
state = await self.client.get_projection_state(projection_name)
self.assertIn("count", state.value)
self.assertEqual(2, state.value["count"])

Expand Down
34 changes: 15 additions & 19 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6392,17 +6392,15 @@ def test_get_projection_state(self) -> None:

# Raises NotFound unless projection exists.
with self.assertRaises(NotFound):
self.client.get_projection_state(name=projection_name, partition="")
self.client.get_projection_state(name=projection_name)

# Create named projection (query is an empty string).
self.client.create_projection(query="", name=projection_name)

# Try to get projection state.
# Todo: Why does this just hang?
with self.assertRaises(DeadlineExceeded):
self.client.get_projection_state(
name=projection_name, partition="", timeout=1
)
self.client.get_projection_state(name=projection_name, timeout=1)

# Create named projection.
projection_name = str(uuid4())
Expand All @@ -6412,7 +6410,7 @@ def test_get_projection_state(self) -> None:
)

# Get projection state.
state = self.client.get_projection_state(name=projection_name, partition="")
state = self.client.get_projection_state(name=projection_name)
self.assertEqual(state.value, {})

def test_get_projection_result(self) -> None:
Expand All @@ -6421,17 +6419,15 @@ def test_get_projection_result(self) -> None:

# Raises NotFound unless projection exists.
with self.assertRaises(NotFound):
self.client.get_projection_result(name=projection_name, partition="")
self.client.get_projection_result(name=projection_name)

# Create named projection.
self.client.create_projection(query="", name=projection_name)

# Try to get projection result.
# Todo: Why does this just hang?
with self.assertRaises(DeadlineExceeded):
self.client.get_projection_result(
name=projection_name, partition="", timeout=1
)
self.client.get_projection_result(name=projection_name, timeout=1)

# Create named projection.
projection_name = str(uuid4())
Expand All @@ -6441,7 +6437,7 @@ def test_get_projection_result(self) -> None:
)

# Get projection result.
state = self.client.get_projection_result(name=projection_name, partition="")
state = self.client.get_projection_result(name=projection_name)
self.assertEqual(state.value, {})

def test_restart_projections_subsystem(self) -> None:
Expand Down Expand Up @@ -6527,12 +6523,12 @@ def test_projection_example(self) -> None:
self.fail("Timed out waiting for two events to be processed by projection")

# Check projection state.
state = self.client.get_projection_state(projection_name, partition="")
state = self.client.get_projection_state(projection_name)
self.assertEqual(2, state.value["count"])

# Check projection result.
# Todo: What's the actual difference between "state" and "result"?
result = self.client.get_projection_result(projection_name, partition="")
result = self.client.get_projection_result(projection_name)
self.assertEqual(2, result.value["count"])

# Check project result stream.
Expand Down Expand Up @@ -6569,9 +6565,9 @@ def test_projection_example(self) -> None:
self.assertEqual("Running", statistics.status)
self.assertLess(0, statistics.events_processed_after_restart)

state = self.client.get_projection_state(projection_name, partition="")
state = self.client.get_projection_state(projection_name)
self.assertIn("count", state.value)
result = self.client.get_projection_result(projection_name, partition="")
result = self.client.get_projection_result(projection_name)
self.assertIn("count", result.value)

# Can't delete whilst running.
Expand All @@ -6590,9 +6586,9 @@ def test_projection_example(self) -> None:
self.assertEqual("Stopped", statistics.status)

# Check projection still has state.
state = self.client.get_projection_state(projection_name, partition="")
state = self.client.get_projection_state(projection_name)
self.assertIn("count", state.value)
result = self.client.get_projection_result(projection_name, partition="")
result = self.client.get_projection_result(projection_name)
self.assertIn("count", result.value)

# Reset whilst stopped is effective (loses state)?
Expand All @@ -6602,17 +6598,17 @@ def test_projection_example(self) -> None:
self.assertEqual("Stopped", statistics.status)
self.assertEqual(0, statistics.events_processed_after_restart)

state = self.client.get_projection_state(projection_name, partition="")
state = self.client.get_projection_state(projection_name)
self.assertNotIn("count", state.value)
result = self.client.get_projection_result(projection_name, partition="")
result = self.client.get_projection_result(projection_name)
self.assertNotIn("count", result.value)

# Can enable after reset.
self.client.enable_projection(name=projection_name)
sleep(1)
statistics = self.client.get_projection_statistics(name=projection_name)
self.assertEqual("Running", statistics.status)
state = self.client.get_projection_state(projection_name, partition="")
state = self.client.get_projection_state(projection_name)
self.assertIn("count", state.value)
self.assertEqual(2, state.value["count"])

Expand Down

0 comments on commit c9ae0f1

Please sign in to comment.