Package org.jobrunr.jobs.lambdas
Interface IocJobLambdaFromStream<S,T>
-
- Type Parameters:
S
- Your service on which you want to call a background job method.T
- The item returned by the Stream
- All Superinterfaces:
JobRunrJob
,java.io.Serializable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface IocJobLambdaFromStream<S,T> extends JobRunrJob
This is a functional interface which allows you to schedule jobs based on a Stream and a lambda that will be parsed by JobRunr. You may not create an actual instance of this class, instead you use it as follows:Stream<User> userStream = userRepository.getAllUsers(); BackgroundJob.<SomeService, User>enqueue(userStream, (x, user) -> x.doWork("do some work for user " + user.getId()));
or
Stream<User> userStream = userRepository.getAllUsers(); jobScheduler.<SomeService, User>enqueue(userStream, (x, user) -> x.doWork("do some work for user " + user.getId()));
This functional interface allows you to enqueue background jobs for each item in the stream without having an actual instance available of your service. While processing, JobRunr will lookup the actual service in the IoC container or create a new instance using the default constructor.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
accept(S service, T item)
-