Class WebsocketEndpoint
java.lang.Object
io.fluxzero.testserver.websocket.WebsocketEndpoint
- Direct Known Subclasses:
ConsumerEndpoint, EventSourcingEndpoint, KeyValueEndPoint, ProducerEndpoint, SchedulingEndpoint, SearchEndpoint
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Durationprotected static Durationprotected booleanprotected final AtomicBooleanprotected static Duration -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedWebsocketEndpoint(CommandIdempotencyStore commandIdempotencyStore) protectedWebsocketEndpoint(Executor requestExecutor) protectedWebsocketEndpoint(Executor requestExecutor, CommandIdempotencyStore commandIdempotencyStore) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidabort(ServerWebsocketSession session, String reason) createTasks(RequestBatch<?> batch, ServerWebsocketSession session) createTasks(RequestBatch<?> batch, ServerWebsocketSession session, long requestReceivedTimestamp) protected JsonTypedeserializeRequest(ServerWebsocketSession session, byte[] bytes) protected voiddispatchRequest(ServerWebsocketSession session, JsonType request) protected voiddispatchRequest(ServerWebsocketSession session, JsonType request, long requestReceivedTimestamp) protected voiddoSendResult(ServerWebsocketSession session, RequestResult result) protected Optional<WebsocketEndpoint.SessionBacklog> findAlternativeBacklog(ServerWebsocketSession closedSession) protected StringgetClientId(ServerWebsocketSession session) protected StringgetClientName(ServerWebsocketSession session) protected Stringprotected CompressionAlgorithmprotected StringgetNamespace(ServerWebsocketSession session) protected StringgetRequestHeaders(ServerWebsocketSession session) protected Stringprotected WebSocketTransportFormatgetTransportFormat(ServerWebsocketSession session) protected voidhandleMessage(ServerWebsocketSession session, JsonType message) protected voidhandleMessage(ServerWebsocketSession session, JsonType message, long requestReceivedTimestamp) protected ExecutorService[]newRequestStripeExecutors(int stripes) voidonClose(ServerWebsocketSession session, WebsocketCloseReason closeReason) voidonError(ServerWebsocketSession session, Throwable e) voidonMessage(byte[] bytes, ServerWebsocketSession session) voidonOpen(ServerWebsocketSession session) voidonPong(ByteBuffer message, ServerWebsocketSession session) protected voidregisterMetrics(Object event, ServerWebsocketSession session) protected WebsocketEndpoint.PingRegistrationschedulePing(ServerWebsocketSession session) protected voidsendPing(ServerWebsocketSession session) protected voidsendResultBatch(ServerWebsocketSession session, List<RequestResult> results) protected CompletableFuture<Void> sendResultBatchAsync(ServerWebsocketSession session, List<RequestResult> results) protected MetadatasessionMetadata(ServerWebsocketSession session) protected booleanshouldHandleIdempotently(Command command) protected voidshutDown()Close all sessions on the websocket after an optional delay.protected booleansubmitRequestTask(ServerWebsocketSession session, JsonType request, Runnable task) protected WebSocketTransportCodectransportCodec(ServerWebsocketSession session)
-
Field Details
-
webSocketSendTimeout
-
pingTimeout
-
pingDelay
-
shuttingDown
-
shutDown
protected volatile boolean shutDown
-
-
Constructor Details
-
WebsocketEndpoint
protected WebsocketEndpoint() -
WebsocketEndpoint
-
WebsocketEndpoint
-
WebsocketEndpoint
protected WebsocketEndpoint(Executor requestExecutor, CommandIdempotencyStore commandIdempotencyStore)
-
-
Method Details
-
onOpen
-
deserializeRequest
protected JsonType deserializeRequest(ServerWebsocketSession session, byte[] bytes) throws IOException - Throws:
IOException
-
onMessage
-
dispatchRequest
-
dispatchRequest
protected void dispatchRequest(ServerWebsocketSession session, JsonType request, long requestReceivedTimestamp) -
shouldHandleIdempotently
-
submitRequestTask
protected boolean submitRequestTask(ServerWebsocketSession session, JsonType request, Runnable task) -
handleMessage
-
handleMessage
protected void handleMessage(ServerWebsocketSession session, JsonType message, long requestReceivedTimestamp) -
doSendResult
-
createTasks
-
createTasks
protected Stream<Runnable> createTasks(RequestBatch<?> batch, ServerWebsocketSession session, long requestReceivedTimestamp) -
sendResultBatch
-
sendResultBatchAsync
protected CompletableFuture<Void> sendResultBatchAsync(ServerWebsocketSession session, List<RequestResult> results) -
findAlternativeBacklog
protected Optional<WebsocketEndpoint.SessionBacklog> findAlternativeBacklog(ServerWebsocketSession closedSession) -
schedulePing
-
sendPing
-
onPong
-
abort
-
onClose
-
onError
-
shutDown
protected void shutDown()Close all sessions on the websocket after an optional delay. During the delay we don't handle new requests but will be able to send back results. -
newRequestStripeExecutors
-
getCompressionAlgorithm
-
getTransportFormat
-
transportCodec
-
getRequestHeaders
-
getNamespace
-
getClientId
-
getClientName
-
getClientSdkVersion
-
getRuntimeVersion
-
getNegotiatedSessionId
-
registerMetrics
-
sessionMetadata
-