This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.concurrent.TimeUnit; | |
import java.util.function.Supplier; | |
import java.util.stream.Collectors; | |
import io.micrometer.core.instrument.FunctionCounter; | |
import io.micrometer.core.instrument.Gauge; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void refreshIpAddressDetails() { | |
LocalDateTime dateTime = LocalDateTime.now().minusDays(90); | |
repository.findByUpdatedAtLessThan(dateTime) | |
.buffer(300) | |
.parallel(2) | |
.flatMap(this::updateIpAddressDetails) | |
.subscribe(System.out::println, System.err::println); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Person { | |
private final String id; | |
private final String firstname; | |
private final String lastname; | |
private final IpAddress ipAddress; // immutable inside | |
public Person(String id, String firstname, String lastname, IpAddress ipAddress) { | |
this.id = id; | |
this.firstname = firstname; | |
this.lastname = lastname; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Mono<Person> addPerson(Mono<Person> mono) { | |
return mono | |
.flatMap(this::addIpAddressDetails) | |
.flatMap(repository::save); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Person addPerson(Person person) { | |
IpAddressDetails ipDetails = ipService.getDetails(person.getIpAddress()); | |
person.setIpAddressDetails(ipDetails); | |
return repository.save(person); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class SchedulerConfiguration { | |
private final Integer connectionPoolSize; | |
public SchedulerConfiguration(@Value("${spring.datasource.maximum-pool-size}") Integer connectionPoolSize) { | |
this.connectionPoolSize = connectionPoolSize; | |
} | |
@Bean | |
public Scheduler jdbcScheduler() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class AddressService { | |
private final AddressRepository repository; | |
private final Scheduler scheduler; | |
public AddressRouter(AddressRepository repository, @Qualifier("jdbcScheduler") Scheduler scheduler) { | |
this.repository = repository; | |
this.scheduler = scheduler; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.data.repository.CrudRepository; | |
public interface AddressRepository extends CrudRepository<Address, Long> {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.net.ssl._ | |
import play.core.ApplicationProvider | |
import play.server.api._ | |
class SSLEngineProviderWithClientAuth(appProvider: ApplicationProvider) extends SSLEngineProvider { | |
override def createSSLEngine(): SSLEngine = { | |
val sslEngine = SSLContext.getDefault.createSSLEngine | |
sslEngine.setNeedClientAuth(true) | |
sslEngine | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Action handling JSON serialization | |
*/ | |
object JsAction { | |
def apply[R](block: R => Result)(implicit reads: Reads[R]) = Action(parse.json) { request => | |
request.body.validate[R](reads).fold( | |
valid = block, | |
invalid = e => { | |
BadRequest(s"Failed validation of JSON request ${request.uri} with errors: ${e.mkString}") |
NewerOlder