akka-projection
akka-projection copied to clipboard
Missing feature: Parse projection ID string into ProjectionId
When using the projection management capabilities, one has to use ProjectionId
s. If one would like to offer a HTTP API to, let's say, reset a projection, the HTTP protocol obviously only allows for conveying the projection ID via string values, e.g. PUT http host:666/projections/myprojection-one ...
. Therefore one needs to be able to parse a projection ID string like myprojection-one
into a ProjectionId
.
The solution looks simple, e.g. def apply(id: String): ProjectionId = // parse around hyphen
, but currently the name
and key
parts of the projection ID are almost not restricted at all, in particular they could contain hyphens which makes the above ambiguous.
Therefore we could restrict (constraints liberate!) the name
and key
parts to, let's say alphanumeric characters, which would also allow for the projection ID strings to be used as parts of resource names (hostname labels in the URL spec). Of course this is a breaking change, but as this project is new and the likelihood that users would use complex names is rather low, I think it's worth it.
If we add a constraint now we will potentially break user's code and we'll have to document and communicate about it. And users will have to migrate their offset store.
To migrate the offset store they will have to shut down their application as a rolling upgrade won't be possible. If we have the API for pause and resume projections, that would be feasible.
- pause projections
- update offset-store
- re-deploy with rolling update and automatically resume projections
We would have a short interruption on the read-side, but the write-side would still be functioning.
However, we may have some alternatives. We could have a method as ProjectionId.parse(str: String)
or ProjectionId.fromString(str: String)
that would fail if the string has more than one -
.
As such we won't break user's application. And if they really want to use it, they will need to make sure that they conform with that constraint. If they don't, but still want to do it, they can either write their own parser or rename the projection id in the offset store.