Class ResponseTimeout
java.lang.Object
services.moleculer.service.MoleculerComponent
services.moleculer.service.Service
services.moleculer.web.middleware.HttpMiddleware
services.moleculer.web.middleware.ResponseTimeout
- All Implemented Interfaces:
services.moleculer.service.MoleculerLifecycle, HttpConstants
Middleware that will timeout requests if the response has not been written
after the specified time. HTTP response code will be "408". Sample:
route.use(new ResponseTimeout(1000L * 30));
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]protected byte[]protected StringTemplate of the HTML response.protected StringTemplate path of the HTML response.protected ScheduledExecutorServiceprotected intResponse status (408 = Request Timeout).protected longRequest timeout in MILLISECONDS (0 = no timeout / disable timer).Fields inherited from class services.moleculer.service.MoleculerComponent
broker, logger, nameFields inherited from interface HttpConstants
ACCEPT, ACCEPT_ENCODING, AUTHORIZATION, CACHE_CONTROL, CHUNKED, CLOSE, CONNECT, CONNECTION, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE, CONTENT_TYPE_HTML, CONTENT_TYPE_JSON, COOKIE, DEFLATE, DELETE, ETAG, GET, GZIP, HEAD, IF_NONE_MATCH, KEEP_ALIVE, LOCATION, META_CONTENT_TYPE, META_HEADERS, META_LOCALE, META_LOCATION, META_SESSION, META_STATUS, META_TEMPLATE, NO_CACHE, OPTIONS, PATCH, POST, PROPERTY_COOKIES, PROPERTY_SESSION_ID, PROPERTY_USER, PUT, SET_COOKIE, TRACE, TRANSFER_ENCODING, WWW_AUTHENTICATE, X_FORWARDED_FOR -
Constructor Summary
ConstructorsConstructorDescriptionResponseTimeout(long timeoutMillis) ResponseTimeout(long timeoutMillis, int status, String htmlTemplateOrPath) -
Method Summary
Modifier and TypeMethodDescriptionintlonginstall(RequestProcessor next, io.datatree.Tree config) protected voidvoidsetHtmlTemplate(String htmlTemplate) voidsetHtmlTemplatePath(String htmlTemplatePath) voidsetStatus(int status) voidsetTimeout(long timeout) voidstarted(services.moleculer.ServiceBroker broker) Methods inherited from class services.moleculer.service.MoleculerComponent
getBroker, getLogger, getName, stopped
-
Field Details
-
timeout
protected long timeoutRequest timeout in MILLISECONDS (0 = no timeout / disable timer). -
status
protected int statusResponse status (408 = Request Timeout). -
htmlTemplate
Template of the HTML response. -
htmlTemplatePath
Template path of the HTML response. -
scheduler
-
cachedHTML
protected byte[] cachedHTML -
cachedJSON
protected byte[] cachedJSON
-
-
Constructor Details
-
ResponseTimeout
public ResponseTimeout() -
ResponseTimeout
public ResponseTimeout(long timeoutMillis) -
ResponseTimeout
-
-
Method Details
-
started
-
install
- Specified by:
installin classHttpMiddleware
-
refreshCaches
protected void refreshCaches() -
getTimeout
public long getTimeout() -
setTimeout
public void setTimeout(long timeout) -
getHtmlTemplate
- Returns:
- the htmlTemplate
-
setHtmlTemplate
- Parameters:
htmlTemplate- the htmlTemplate to set
-
getHtmlTemplatePath
- Returns:
- the htmlTemplatePath
-
setHtmlTemplatePath
- Parameters:
htmlTemplatePath- the htmlTemplatePath to set
-
getStatus
public int getStatus()- Returns:
- the status
-
setStatus
public void setStatus(int status) - Parameters:
status- the status to set
-