Search in sources :

Example 1 with Duration

use of com.uber.m3.util.Duration in project cadence-client by uber-java.

the class NoopScope method getInstance.

public static synchronized Scope getInstance() {
    if (noopScope == null) {
        noopCounter = delta -> {
        };
        noopGauge = value -> {
        };
        noopTimer = new Timer() {

            @Override
            public void record(Duration interval) {
            }

            @Override
            public Stopwatch start() {
                return new Stopwatch(0, stopwatchStart -> {
                });
            }
        };
        noopHistogram = new Histogram() {

            @Override
            public void recordValue(double value) {
            }

            @Override
            public void recordDuration(Duration value) {
            }

            @Override
            public Stopwatch start() {
                return new Stopwatch(0, stopwatchStart -> {
                });
            }
        };
        noopScope = new NoopScope();
    }
    return noopScope;
}
Also used : Stopwatch(com.uber.m3.tally.Stopwatch) Scope(com.uber.m3.tally.Scope) Timer(com.uber.m3.tally.Timer) CapableOf(com.uber.m3.tally.CapableOf) Map(java.util.Map) Counter(com.uber.m3.tally.Counter) Histogram(com.uber.m3.tally.Histogram) Capabilities(com.uber.m3.tally.Capabilities) Gauge(com.uber.m3.tally.Gauge) Duration(com.uber.m3.util.Duration) Buckets(com.uber.m3.tally.Buckets) Histogram(com.uber.m3.tally.Histogram) Timer(com.uber.m3.tally.Timer) Stopwatch(com.uber.m3.tally.Stopwatch) Duration(com.uber.m3.util.Duration)

Example 2 with Duration

use of com.uber.m3.util.Duration in project sdk-java by temporalio.

the class ReplayWorkflowContextImpl method newTimer.

@Override
public Functions.Proc1<RuntimeException> newTimer(Duration delay, Functions.Proc1<RuntimeException> callback) {
    if (delay.compareTo(Duration.ZERO) <= 0) {
        callback.apply(null);
        return (e) -> {
        };
    }
    StartTimerCommandAttributes attributes = StartTimerCommandAttributes.newBuilder().setStartToFireTimeout(ProtobufTimeUtils.toProtoDuration(delay)).setTimerId(workflowStateMachines.randomUUID().toString()).build();
    Functions.Proc cancellationHandler = workflowStateMachines.newTimer(attributes, (event) -> handleTimerCallback(callback, event));
    return (e) -> cancellationHandler.apply();
}
Also used : Payloads(io.temporal.api.common.v1.Payloads) ProtobufTimeUtils(io.temporal.internal.common.ProtobufTimeUtils) WorkflowStateMachines(io.temporal.internal.statemachines.WorkflowStateMachines) Func1(io.temporal.workflow.Functions.Func1) Random(java.util.Random) WorkflowTaskFailedCause(io.temporal.api.enums.v1.WorkflowTaskFailedCause) Func(io.temporal.workflow.Functions.Func) Functions(io.temporal.workflow.Functions) Duration(java.time.Duration) Map(java.util.Map) CanceledFailure(io.temporal.failure.CanceledFailure) SingleWorkerOptions(io.temporal.internal.worker.SingleWorkerOptions) WorkflowType(io.temporal.api.common.v1.WorkflowType) RequestCancelExternalWorkflowExecutionCommandAttributes(io.temporal.api.command.v1.RequestCancelExternalWorkflowExecutionCommandAttributes) SignalExternalWorkflowExecutionCommandAttributes(io.temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes) ContextPropagator(io.temporal.common.context.ContextPropagator) Scope(com.uber.m3.tally.Scope) WorkflowExecution(io.temporal.api.common.v1.WorkflowExecution) ScheduleActivityTaskCommandAttributes(io.temporal.api.command.v1.ScheduleActivityTaskCommandAttributes) Payload(io.temporal.api.common.v1.Payload) Failure(io.temporal.api.failure.v1.Failure) StartTimerCommandAttributes(io.temporal.api.command.v1.StartTimerCommandAttributes) UUID(java.util.UUID) ContinueAsNewWorkflowExecutionCommandAttributes(io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes) HistoryEvent(io.temporal.api.history.v1.HistoryEvent) List(java.util.List) Optional(java.util.Optional) SearchAttributes(io.temporal.api.common.v1.SearchAttributes) WorkflowTaskFailedEventAttributes(io.temporal.api.history.v1.WorkflowTaskFailedEventAttributes) WorkflowExecutionStartedEventAttributes(io.temporal.api.history.v1.WorkflowExecutionStartedEventAttributes) StartTimerCommandAttributes(io.temporal.api.command.v1.StartTimerCommandAttributes) Functions(io.temporal.workflow.Functions)

Aggregations

Scope (com.uber.m3.tally.Scope)2 Map (java.util.Map)2 Buckets (com.uber.m3.tally.Buckets)1 Capabilities (com.uber.m3.tally.Capabilities)1 CapableOf (com.uber.m3.tally.CapableOf)1 Counter (com.uber.m3.tally.Counter)1 Gauge (com.uber.m3.tally.Gauge)1 Histogram (com.uber.m3.tally.Histogram)1 Stopwatch (com.uber.m3.tally.Stopwatch)1 Timer (com.uber.m3.tally.Timer)1 Duration (com.uber.m3.util.Duration)1 ContinueAsNewWorkflowExecutionCommandAttributes (io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes)1 RequestCancelExternalWorkflowExecutionCommandAttributes (io.temporal.api.command.v1.RequestCancelExternalWorkflowExecutionCommandAttributes)1 ScheduleActivityTaskCommandAttributes (io.temporal.api.command.v1.ScheduleActivityTaskCommandAttributes)1 SignalExternalWorkflowExecutionCommandAttributes (io.temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes)1 StartTimerCommandAttributes (io.temporal.api.command.v1.StartTimerCommandAttributes)1 Payload (io.temporal.api.common.v1.Payload)1 Payloads (io.temporal.api.common.v1.Payloads)1 SearchAttributes (io.temporal.api.common.v1.SearchAttributes)1 WorkflowExecution (io.temporal.api.common.v1.WorkflowExecution)1