This file contains 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
--- contention: | |
cycles/second=3500003374 | |
36366201471709872 346351 @ 0x441012 0x65c60e 0x463bc1 | |
# 0x441012 runtime.selectgo+0x12 /usr/local/go/src/runtime/select.go:215 | |
# 0x65c60e github.com/influxdata/influxdb/tsdb.(*Shard).monitorSize+0x28e /root/go/src/github.com/influxdata/influxdb/tsdb/shard.go:701 | |
1478399522858787 704 @ 0x441012 0x636e39 0x463bc1 | |
# 0x441012 runtime.selectgo+0x12 /usr/local/go/src/runtime/select.go:215 | |
# 0x636e39 github.com/influxdata/influxdb/services/precreator.(*Service).runPrecreation+0x3f9 /root/go/src/github.com/influxdata/influxdb/services/precreator/service.go:77 |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<body> | |
<script>alert(1)</script> | |
</body> |
This file contains 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
var a = 0 | |
fun counter() { | |
a++ | |
println(a) | |
} | |
fun main() { | |
counter() | |
counter() |
This file contains 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
class TeaPotService { | |
fun turnOn() { | |
//do something | |
} | |
fun turnOff() { | |
//do something | |
} | |
} | |
fun main() { |
This file contains 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
if (turnOnTheTeaPot) { | |
// Turning teapot on | |
teaPotService.turnOn() | |
teaPotTurnedOn = true | |
} else { | |
// Turning teapot off | |
teaPotService.turnOff() | |
teaPotTurnedOn = false | |
} |
This file contains 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
fun turnOnTheTeaPot(teapotService: TeaPotService) : Boolean { | |
teaPotService.turnOn() | |
return true | |
} | |
fun turnOffTheTeaPot(teapotService: TeaPotService) : Boolean { | |
teaPotService.turnOff() | |
return false | |
} |
This file contains 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
val teaPotTurnedOn = if (turnOnTheTeaPot) { | |
// region Turning teapot on | |
teaPotService.turnOn() | |
true | |
// endregion | |
} else { | |
// region Turning teapot off | |
teaPotService.turnOff() | |
false | |
// endregion |
This file contains 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
sealed class State(val previousState: State?) { | |
class RequestReceived(val request: Int): State(null) | |
class RequestValidated(val validationResult: Boolean, previousState: RequestReceived): State(previousState) | |
class RequestProcessed(val response: Int, previousState: RequestValidated): State(previousState) | |
class ResponseValidated(val validationResult: Boolean, previousState: RequestProcessed): State(previousState) | |
} |
This file contains 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
abstract class Transition<InputState: State, OutputState: State> { | |
abstract fun invoke(state: InputState) : OutputState | |
} | |
class ValidateRequest: Transition<State.RequestReceived, State.RequestValidated>() { | |
override fun invoke(state: State.RequestReceived): State.RequestValidated { | |
// let's just check something here | |
return State.RequestValidated(state.request > 0, state) | |
} | |
} |
This file contains 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
fun List<Transition<State, State>>.fold(initial: State.RequestReceived): State.ResponseValidated { | |
var currentState: State = initial | |
forEach { | |
currentState = it.invoke(currentState) | |
} | |
if (currentState is State.ResponseValidated) { | |
return currentState as State.ResponseValidated | |
} else { | |
throw IllegalStateException("currentState is not of State.ResponseValidated type") | |
} |
OlderNewer