public interface DeviceRegistry
registry
.getDevice(deviceId)
.flatMap(device->device.getSelfConfig("my-config"))
.flatMap(conf-> doSomeThing(...))
| 限定符和类型 | 方法和说明 |
|---|---|
default reactor.core.publisher.Flux<DeviceStateInfo> |
checkDeviceState(reactor.core.publisher.Flux<? extends Collection<String>> id)
批量检查设备真实状态,建议使用
DeviceOperator.checkState() |
reactor.core.publisher.Mono<DeviceOperator> |
getDevice(String deviceId)
获取设备操作接口.如果设备未注册或者注册已失效(缓存丢失).则回返回
Mono.empty(),
可以通过Mono.switchIfEmpty(Mono)来处理设备不存在的情况.如:
registry
.getDevice(deviceId)
.switchIfEmpty(Mono.error(()->new DeviceNotFoundException(....))) |
reactor.core.publisher.Mono<DeviceProductOperator> |
getProduct(String productId)
获取设备产品操作,请勿缓存返回值,注册中心已经实现本地缓存.
|
default reactor.core.publisher.Mono<DeviceProductOperator> |
getProduct(String productId,
String version)
获取指定版本的产品,在注册产品时,指定了产品版本
ProductInfo#getVersion()的信息,可以通过此方法获取 |
reactor.core.publisher.Mono<DeviceOperator> |
register(DeviceInfo deviceInfo)
注册设备,并返回设备操作接口,请勿缓存返回值,注册中心已经实现本地缓存.
|
reactor.core.publisher.Mono<DeviceProductOperator> |
register(ProductInfo productInfo)
注册产品(型号)信息
|
reactor.core.publisher.Mono<Void> |
unregisterDevice(String deviceId)
注销设备,注销后将无法通过
getDevice(String)获取到设备信息,
此操作将触发ProtocolSupport.onDeviceUnRegister(DeviceOperator) |
reactor.core.publisher.Mono<Void> |
unregisterProduct(String productId)
注销产品,注销后将无法通过
getProduct(String) 获取到产品信息
此操作只会注销未设置版本的产品. |
default reactor.core.publisher.Mono<Void> |
unregisterProduct(String productId,
String version)
注销指定版本的产品,注销后将无法通过
getProduct(String,String) 获取到产品信息
此操作将触发 ProtocolSupport.onProductUnRegister(DeviceProductOperator) |
reactor.core.publisher.Mono<DeviceOperator> getDevice(String deviceId)
Mono.empty(),
可以通过Mono.switchIfEmpty(Mono)来处理设备不存在的情况.如:
registry
.getDevice(deviceId)
.switchIfEmpty(Mono.error(()->new DeviceNotFoundException(....)))
deviceId - 设备IDdefault reactor.core.publisher.Flux<DeviceStateInfo> checkDeviceState(reactor.core.publisher.Flux<? extends Collection<String>> id)
DeviceOperator.checkState()id - IDreactor.core.publisher.Mono<DeviceProductOperator> getProduct(String productId)
productId - 产品IDdefault reactor.core.publisher.Mono<DeviceProductOperator> getProduct(String productId, String version)
ProductInfo#getVersion()的信息,可以通过此方法获取productId - 产品IDversion - 版本号reactor.core.publisher.Mono<DeviceOperator> register(DeviceInfo deviceInfo)
deviceInfo - 设备基础信息getDevice(String)reactor.core.publisher.Mono<DeviceProductOperator> register(ProductInfo productInfo)
productInfo - 产品(型号)信息reactor.core.publisher.Mono<Void> unregisterDevice(String deviceId)
getDevice(String)获取到设备信息,
此操作将触发ProtocolSupport.onDeviceUnRegister(DeviceOperator)deviceId - 设备IDreactor.core.publisher.Mono<Void> unregisterProduct(String productId)
getProduct(String) 获取到产品信息
ProtocolSupport.onProductUnRegister(DeviceProductOperator)productId - 产品IDdefault reactor.core.publisher.Mono<Void> unregisterProduct(String productId, String version)
getProduct(String,String) 获取到产品信息
ProtocolSupport.onProductUnRegister(DeviceProductOperator)productId - 产品IDversion - 版本号Copyright © 2019–2022. All rights reserved.