Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow LogRotatorSink be a Sink[T] instead of Sink[ByteString] #2323

Merged
merged 3 commits into from
May 27, 2020
Merged

Allow LogRotatorSink be a Sink[T] instead of Sink[ByteString] #2323

merged 3 commits into from
May 27, 2020

Conversation

shagoon
Copy link
Contributor

@shagoon shagoon commented May 20, 2020

The current implementation of LogRotatorSink works well for time-based rotation, if the time is the real time. It does not fit well, if the time to trigger on is contained in the stream itself, since the stream is already of type ByteString. You had to parse that ByteString to gain access to the time contained in the data (or anything else you would like to trigger on).

This PR slightly modifies LogRotatorSink to accept an additional type parameter T. The triggerGeneratorCreator function becomes T => Option[C], the sinkFactory becomes C => Sink[T, Future[R]]. This allows to trigger on data contained in T, the sink also works on T and probably uses a transformer T => ByteString. For details, have a look at the new test in LogRotatorSinkSpec.

@ennru
Copy link
Member

ennru commented May 26, 2020

Hi @shagoon,

Thank you for your suggestion to make the log rotator more versatile!

Can you re-work your suggestion a bit so that the current withSinkFactory API in the object LogRotatorSink stays as before and just add new methods to support extracting the timestamp from the data?

@shagoon
Copy link
Contributor Author

shagoon commented May 26, 2020

Hi @ennru,

thanks for you feedback. Yes, I can try to rework my changes as you suggested, but, could you please explain, why you suggested those changes? The way I implemented withSinkFactory requires no further changes in existing code (i.e. the existing test in LogRotatorSinkSpec utilising withSinkFactory had not to be modified). I guess binary compatibility is an issue here?

If I introduce a new method to the object LogRotatorSink, this method would have the same signature as the existing one (after type erasure), so, a different name would be required. Any suggestions?

@ennru
Copy link
Member

ennru commented May 26, 2020

The goal is to stay binary-compatible in the public API.
See https://travis-ci.com/github/akka/alpakka/jobs/338190546#L669

You will need to add Mima exclusions to make it accept the changes to the LogRotatorSink stage class.

Maybe genericSinkFactory or withTypedSinkFactory?

@shagoon
Copy link
Contributor Author

shagoon commented May 26, 2020

I see. I just pushed an update with withSinkFactory reverted to the original code and an additional method withTypedSinkFactory (which I liked more than genericSinkFactory).

Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ennru ennru added this to the 2.0.1 milestone May 27, 2020
@ennru ennru merged commit 5534c61 into akka:master May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants