Search in sources :

Example 1 with LogSubscriber

use of com.peterphi.servicemanager.service.logging.hub.LogSubscriber in project stdlib by petergeneric.

the class ServiceManagerUIServiceImpl method getTail.

@Override
public String getTail() {
    final TemplateCall call = templater.template("tail");
    // Create a new subscription to the log stream
    // Also take this opportunity to remove purged subscriptions from the map
    final String subscriptionId = user.getUsername() + "_" + SimpleId.alphanumeric(10);
    synchronized (subscribers) {
        log.info("Created log tail subscription " + subscriptionId);
        subscribers.put(subscriptionId, loggingService.subscribe(new LogSubscriber(subscriptionId)));
        // Remove purged subscribers
        final Iterator<Map.Entry<String, LogSubscriber>> it = subscribers.entrySet().iterator();
        while (it.hasNext()) {
            if (it.next().getValue().isPurged())
                it.remove();
        }
    }
    call.set("nonce", nonceStore.getValue());
    call.set("subscriptionId", subscriptionId);
    return call.process();
}
Also used : LogSubscriber(com.peterphi.servicemanager.service.logging.hub.LogSubscriber) TemplateCall(com.peterphi.std.guice.web.rest.templating.TemplateCall)

Aggregations

LogSubscriber (com.peterphi.servicemanager.service.logging.hub.LogSubscriber)1 TemplateCall (com.peterphi.std.guice.web.rest.templating.TemplateCall)1