Skip to content

Instantly share code, notes, and snippets.

@alxlion
Last active August 18, 2017 20:45
Show Gist options
  • Save alxlion/ce2c81b5d386ecfceb22765b036b33f5 to your computer and use it in GitHub Desktop.
Save alxlion/ce2c81b5d386ecfceb22765b036b33f5 to your computer and use it in GitHub Desktop.
@Scope("singleton")
public class InternalDatabase {
private List<Transaction> memory;
public InternalDatabase() {
if (this.memory == null) {
this.memory = new ArrayList<>();
}
}
public Mono<Transaction> add (Transaction t) {
this.memory.add(t);
return Mono.just(t);
}
public Flux<Transaction> get() {
return Flux
.fromIterable(new ArrayList<>(this.memory))
.delayElements(Duration.ofMillis(300));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment