Skip to content

Commit

Permalink
Add projection manager method to get partition state and result.
Browse files Browse the repository at this point in the history
  • Loading branch information
lscpike committed Dec 5, 2015
1 parent 0b6da4a commit 367f2f3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/EventStore.ClientAPI/Projections/ProjectionsClient.cs
Expand Up @@ -117,6 +117,21 @@ public Task<string> GetState(IPEndPoint endPoint, string name, UserCredentials u
return SendGet(endPoint.ToHttpUrl("/projection/{0}/state", name), userCredentials, HttpStatusCode.OK);
}

public Task<string> 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<string> GetResult(IPEndPoint endPoint, string name, UserCredentials userCredentials = null)
{
return SendGet(endPoint.ToHttpUrl("/projection/{0}/result", name), userCredentials, HttpStatusCode.OK);
}

public Task<string> 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<string> GetStatistics(IPEndPoint endPoint, string name, UserCredentials userCredentials = null)
{
return SendGet(endPoint.ToHttpUrl("/projection/{0}/statistics", name), userCredentials, HttpStatusCode.OK);
Expand Down
42 changes: 41 additions & 1 deletion src/EventStore.ClientAPI/Projections/ProjectionsManager.cs
Expand Up @@ -192,6 +192,46 @@ public Task<string> GetStateAsync(string name, UserCredentials userCredentials =
return _client.GetState(_httpEndPoint, name, userCredentials);
}

/// <summary>
/// Asynchronously gets the state of a projection for a specified partition.
/// </summary>
/// <param name="name">The name of the projection.</param>
/// <param name="partitionId">The id of the partition.</param>
/// <param name="userCredentials">Credentials for the operation.</param>
/// <returns>String of JSON containing projection state.</returns>
public Task<string> GetPartitionStateAsync(string name, string partitionId, UserCredentials userCredentials = null)
{
Ensure.NotNullOrEmpty(name, "name");
Ensure.NotNullOrEmpty(partitionId, "partitionId");
return _client.GetPartitionStateAsync(_httpEndPoint, name, partitionId, userCredentials);
}

/// <summary>
/// Asynchronously gets the state of a projection.
/// </summary>
/// <param name="name">The name of the projection.</param>
/// <param name="userCredentials">Credentials for the operation.</param>
/// <returns>String of JSON containing projection state.</returns>
public Task<string> GetResultAsync(string name, UserCredentials userCredentials = null)
{
Ensure.NotNullOrEmpty(name, "name");
return _client.GetState(_httpEndPoint, name, userCredentials);
}

/// <summary>
/// Asynchronously gets the state of a projection for a specified partition.
/// </summary>
/// <param name="name">The name of the projection.</param>
/// <param name="partitionId">The id of the partition.</param>
/// <param name="userCredentials">Credentials for the operation.</param>
/// <returns>String of JSON containing projection state.</returns>
public Task<string> GetPartitionResultAsync(string name, string partitionId, UserCredentials userCredentials = null)
{
Ensure.NotNullOrEmpty(name, "name");
Ensure.NotNullOrEmpty(partitionId, "partitionId");
return _client.GetPartitionStateAsync(_httpEndPoint, name, partitionId, userCredentials);
}

/// <summary>
/// Asynchronously gets the statistics of a projection.
/// </summary>
Expand Down Expand Up @@ -242,4 +282,4 @@ public Task DeleteAsync(string name, UserCredentials userCredentials = null)
return _client.Delete(_httpEndPoint, name, userCredentials);
}
}
}
}

0 comments on commit 367f2f3

Please sign in to comment.