@Test public void register() { Registration registration = Registration.create("abc", "http: InstanceId id = registry.register(registration).block(); StepVerifier.create(registry.getInstance(id)).assertNext(app -> { assertThat(app.getRegistration()).isEqualTo(registration); assertThat(app.getId()).isNotNull(); }).verifyComplete(); StepVerifier.create(registry.getInstances()).assertNext(app -> { assertThat(app.getRegistration()).isEqualTo(registration); assertThat(app.getId()).isNotNull(); }).verifyComplete(); }
public Mono<InstanceId> register(Registration registration) { Assert.notNull(registration, "'registration' must not be null"); InstanceId id = generator.generateId(registration); Assert.notNull(id, "'id' must not be null"); return repository.compute(id, (key, instance) -> { if (instance == null) { instance = Instance.create(key); } return Mono.just(instance.register(registration)); }).map(Instance::getId); }
InstanceRegistry { public Mono<InstanceId> register(Registration registration) { Assert.notNull(registration, "'registration' must not be null"); InstanceId id = generator.generateId(registration); Assert.notNull(id, "'id' must not be null"); return repository.compute(id, (key, instance) -> { if (instance == null) { instance = Instance.create(key); } return Mono.just(instance.register(registration)); }).map(Instance::getId); } }
InstanceRegistry { public Mono<InstanceId> register(Registration registration) { Assert.notNull(registration, "'registration' must not be null"); InstanceId id = generator.generateId(registration); Assert.notNull(id, "'id' must not be null"); return repository.compute(id, (key, instance) -> { if (instance == null) { instance = Instance.create(key); } return Mono.just(instance.register(registration)); }).map(Instance::getId); } InstanceRegistry(InstanceRepository repository, InstanceIdGenerator generator); }
InstanceRegistry { public Mono<InstanceId> register(Registration registration) { Assert.notNull(registration, "'registration' must not be null"); InstanceId id = generator.generateId(registration); Assert.notNull(id, "'id' must not be null"); return repository.compute(id, (key, instance) -> { if (instance == null) { instance = Instance.create(key); } return Mono.just(instance.register(registration)); }).map(Instance::getId); } InstanceRegistry(InstanceRepository repository, InstanceIdGenerator generator); Mono<InstanceId> register(Registration registration); Flux<Instance> getInstances(); Flux<Instance> getInstances(String name); Mono<Instance> getInstance(InstanceId id); Mono<InstanceId> deregister(InstanceId id); }
InstanceRegistry { public Mono<InstanceId> register(Registration registration) { Assert.notNull(registration, "'registration' must not be null"); InstanceId id = generator.generateId(registration); Assert.notNull(id, "'id' must not be null"); return repository.compute(id, (key, instance) -> { if (instance == null) { instance = Instance.create(key); } return Mono.just(instance.register(registration)); }).map(Instance::getId); } InstanceRegistry(InstanceRepository repository, InstanceIdGenerator generator); Mono<InstanceId> register(Registration registration); Flux<Instance> getInstances(); Flux<Instance> getInstances(String name); Mono<Instance> getInstance(InstanceId id); Mono<InstanceId> deregister(InstanceId id);  }