timeout 40s /bin/bash -c "while ! httping -qc1 http://somehost:8080/app ; do sleep 1 ; done; echo OK" || echo TIMEOUTIf the service cannot be reached within 40s then TIMEOUT will be printed otherwise OK.
timeout 40s /bin/bash -c "while ! httping -qc1 http://somehost:8080/app ; do sleep 1 ; done; echo OK" || echo TIMEOUTIf the service cannot be reached within 40s then TIMEOUT will be printed otherwise OK.
| package com.example.feed | |
| import com.rometools.rome.feed.synd.SyndEntry | |
| import org.springframework.boot.autoconfigure.SpringBootApplication | |
| import org.springframework.boot.builder.SpringApplicationBuilder | |
| import org.springframework.context.support.beans | |
| import org.springframework.core.io.UrlResource | |
| import org.springframework.integration.dsl.IntegrationFlows | |
| import org.springframework.integration.feed.dsl.Feed | |
| import org.springframework.integration.handler.GenericHandler |
| @EnableGateway | |
| @SpringBootApplication | |
| public class SpringCloudGatewayApplication { | |
| private final String cookieName = "beta_active"; | |
| private final String headerName = "X-Beta-active"; | |
| private final String betaActiveValue = "true"; | |
| /** | |
| * They're in the beta if they have a cookie or request header set |
| @EnableWebSecurity | |
| class ApiSecurityConfig extends WebSecurityConfigurerAdapter { | |
| @Inject | |
| void configureGlobal(AuthenticationManagerBuilder auth) { | |
| auth.inMemoryAuthentication() | |
| .withUser('svc_acct').password('somePassword').roles('FULL_ACCESS') | |
| } | |
| @Override | |
| protected void configure(HttpSecurity http) { |
| bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done' | |
| # also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76 |
| // Example of using StAX to split a large XML document and parse a single element using XmlSlurper | |
| import javax.xml.stream.XMLInputFactory | |
| import javax.xml.stream.XMLStreamReader | |
| import javax.xml.transform.Transformer | |
| import javax.xml.transform.TransformerFactory | |
| import javax.xml.transform.sax.SAXResult | |
| import javax.xml.transform.stax.StAXSource | |
| def url = new URL("http://repo2.maven.org/maven2/archetype-catalog.xml") |
| private fun <K, V> Map<K, V>.mergeReduce(other: Map<K, V>, reduce: (V, V) -> V = { a, b -> b }): Map<K, V> { | |
| val result = LinkedHashMap<K, V>(this.size() + other.size()) | |
| result.putAll(this) | |
| other.forEach { e -> | |
| val existing = result[e.key] | |
| if (existing == null) { | |
| result[e.key] = e.value | |
| } | |
| else { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.stream.Collectors; | |
| import java.util.stream.Stream; | |
| /* Efficiency must be questioned | |
| * | |
| * Also, no error checking, so could go infinite if called with dodgy params | |
| * | |
| * (left as an exercise for the reader) ;-) |