From 367f2f3efc2b68367d57af252e118ace68fc7218 Mon Sep 17 00:00:00 2001 From: Laurence Pike Date: Fri, 4 Dec 2015 17:37:05 +0000 Subject: [PATCH] Add projection manager method to get partition state and result. --- .../Projections/ProjectionsClient.cs | 15 +++++++ .../Projections/ProjectionsManager.cs | 42 ++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/EventStore.ClientAPI/Projections/ProjectionsClient.cs b/src/EventStore.ClientAPI/Projections/ProjectionsClient.cs index 3ebd7bf2491..ddfb56d23b3 100644 --- a/src/EventStore.ClientAPI/Projections/ProjectionsClient.cs +++ b/src/EventStore.ClientAPI/Projections/ProjectionsClient.cs @@ -117,6 +117,21 @@ public Task GetState(IPEndPoint endPoint, string name, UserCredentials u return SendGet(endPoint.ToHttpUrl("/projection/{0}/state", name), userCredentials, HttpStatusCode.OK); } + public Task GetPartitionStateAsync(IPEndPoint endPoint, string name, string partition, UserCredentials userCredentials = null) + { + return SendGet(endPoint.ToHttpUrl("/projection/{0}/state?partition={1}", name, partition), userCredentials, HttpStatusCode.OK); + } + + public Task GetResult(IPEndPoint endPoint, string name, UserCredentials userCredentials = null) + { + return SendGet(endPoint.ToHttpUrl("/projection/{0}/result", name), userCredentials, HttpStatusCode.OK); + } + + public Task GetPartitionResultAsync(IPEndPoint endPoint, string name, string partition, UserCredentials userCredentials = null) + { + return SendGet(endPoint.ToHttpUrl("/projection/{0}/result?partition={1}", name, partition), userCredentials, HttpStatusCode.OK); + } + public Task GetStatistics(IPEndPoint endPoint, string name, UserCredentials userCredentials = null) { return SendGet(endPoint.ToHttpUrl("/projection/{0}/statistics", name), userCredentials, HttpStatusCode.OK); diff --git a/src/EventStore.ClientAPI/Projections/ProjectionsManager.cs b/src/EventStore.ClientAPI/Projections/ProjectionsManager.cs index 89601bc11a4..1b1244f41ce 100644 --- a/src/EventStore.ClientAPI/Projections/ProjectionsManager.cs +++ b/src/EventStore.ClientAPI/Projections/ProjectionsManager.cs @@ -192,6 +192,46 @@ public Task GetStateAsync(string name, UserCredentials userCredentials = return _client.GetState(_httpEndPoint, name, userCredentials); } + /// + /// Asynchronously gets the state of a projection for a specified partition. + /// + /// The name of the projection. + /// The id of the partition. + /// Credentials for the operation. + /// String of JSON containing projection state. + public Task GetPartitionStateAsync(string name, string partitionId, UserCredentials userCredentials = null) + { + Ensure.NotNullOrEmpty(name, "name"); + Ensure.NotNullOrEmpty(partitionId, "partitionId"); + return _client.GetPartitionStateAsync(_httpEndPoint, name, partitionId, userCredentials); + } + + /// + /// Asynchronously gets the state of a projection. + /// + /// The name of the projection. + /// Credentials for the operation. + /// String of JSON containing projection state. + public Task GetResultAsync(string name, UserCredentials userCredentials = null) + { + Ensure.NotNullOrEmpty(name, "name"); + return _client.GetState(_httpEndPoint, name, userCredentials); + } + + /// + /// Asynchronously gets the state of a projection for a specified partition. + /// + /// The name of the projection. + /// The id of the partition. + /// Credentials for the operation. + /// String of JSON containing projection state. + public Task GetPartitionResultAsync(string name, string partitionId, UserCredentials userCredentials = null) + { + Ensure.NotNullOrEmpty(name, "name"); + Ensure.NotNullOrEmpty(partitionId, "partitionId"); + return _client.GetPartitionStateAsync(_httpEndPoint, name, partitionId, userCredentials); + } + /// /// Asynchronously gets the statistics of a projection. /// @@ -242,4 +282,4 @@ public Task DeleteAsync(string name, UserCredentials userCredentials = null) return _client.Delete(_httpEndPoint, name, userCredentials); } } -} \ No newline at end of file +}