com.linkedin.parseq.Task.withSideEffect()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中com.linkedin.parseq.Task.withSideEffect()方法的一些代码示例,展示了Task.withSideEffect()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.withSideEffect()方法的具体详情如下:
包路径:com.linkedin.parseq.Task
类名称:Task
方法名:withSideEffect

Task.withSideEffect介绍

[英]Equivalent to withSideEffect("sideEffect", func).
[中]相当于Withideeffect(“sideEffect”,func)。

代码示例

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function1)
 */
default Task<T> withSideEffect(final Function1<? super T, Task<?>> func) {
 return withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), func);
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function2)
 */
default Tuple2Task<T1, T2> withSideEffect(Function2<T1, T2, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2())));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function3)
 */
default Tuple3Task<T1, T2, T3> withSideEffect(Function3<T1, T2, T3, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3())));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function4)
 */
default Tuple4Task<T1, T2, T3, T4> withSideEffect(Function4<T1, T2, T3, T4, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4())));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function5)
 */
default Tuple5Task<T1, T2, T3, T4, T5> withSideEffect(Function5<T1, T2, T3, T4, T5, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5())));
}

代码示例来源:origin: linkedin/parseq

public void testWithSideEffectFuncReturnNulll() {
 Task<String> task = getSuccessTask().withSideEffect(str -> null);
 runAndWaitException("AbstractTaskTest.testWithSideEffectFuncReturnNulll", task, RuntimeException.class);
 assertTrue(task.getError().getMessage().contains("returned null"));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function6)
 */
default Tuple6Task<T1, T2, T3, T4, T5, T6> withSideEffect(Function6<T1, T2, T3, T4, T5, T6, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6())));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function7)
 */
default Tuple7Task<T1, T2, T3, T4, T5, T6, T7> withSideEffect(Function7<T1, T2, T3, T4, T5, T6, T7, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6(), tuple._7())));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function8)
 */
default Tuple8Task<T1, T2, T3, T4, T5, T6, T7, T8> withSideEffect(Function8<T1, T2, T3, T4, T5, T6, T7, T8, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6(), tuple._7(), tuple._8())));
}

代码示例来源:origin: linkedin/parseq

@Test
public void testWithSideEffectPartial() {
 Task<String> fastMain = getSuccessTask();
 Task<String> slowSideEffect = delayedValue("slooow", 5100, TimeUnit.MILLISECONDS);
 Task<String> partial = fastMain.withSideEffect(s -> slowSideEffect);
 // ensure the whole task can finish before individual side effect task finishes
 runAndWait("AbstractTaskTest.testWithSideEffectPartial", partial);
 assertTrue(fastMain.isDone());
 assertTrue(partial.isDone());
 assertFalse(slowSideEffect.isDone());
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function9)
 */
default Tuple9Task<T1, T2, T3, T4, T5, T6, T7, T8, T9> withSideEffect(Function9<T1, T2, T3, T4, T5, T6, T7, T8, T9, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6(), tuple._7(), tuple._8(), tuple._9())));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function10)
 */
default Tuple10Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> withSideEffect(Function10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6(), tuple._7(), tuple._8(), tuple._9(), tuple._10())));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function11)
 */
default Tuple11Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> withSideEffect(Function11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6(), tuple._7(), tuple._8(), tuple._9(), tuple._10(), tuple._11())));
}

代码示例来源:origin: linkedin/parseq

@Test
public void testWithSideEffectTaskType() {
 Task<?> taskWithSideEffect = Task.value("value1Task", "value1").withSideEffect("delayed sideEffect",
   v -> delayedValue("value2", 100, TimeUnit.MILLISECONDS));
 runAndWait("taskWithSideEffectTaskType", taskWithSideEffect);
 Assert.assertEquals(taskWithSideEffect.getShallowTrace().getTaskType(), TaskType.WITH_SIDE_EFFECT.getName());
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function12)
 */
default Tuple12Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> withSideEffect(Function12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6(), tuple._7(), tuple._8(), tuple._9(), tuple._10(), tuple._11(), tuple._12())));
}

代码示例来源:origin: linkedin/parseq

public void testWithSideEffectFullCompletion(int expectedNumberOfTasks) throws Exception {
 Task<String> fastMain = getSuccessTask();
 Task<String> slowSideEffect = delayedValue("slow", 50, TimeUnit.MILLISECONDS);
 Task<String> full = fastMain.withSideEffect(s -> slowSideEffect);
 // ensure the side effect task will be run
 runAndWait("AbstractTaskTest.testWithSideEffectFullCompletion", full);
 slowSideEffect.await();
 assertTrue(full.isDone());
 assertTrue(fastMain.isDone());
 assertTrue(slowSideEffect.isDone());
 assertEquals(countTasks(full.getTrace()), expectedNumberOfTasks);
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function13)
 */
default Tuple13Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> withSideEffect(Function13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6(), tuple._7(), tuple._8(), tuple._9(), tuple._10(), tuple._11(), tuple._12(), tuple._13())));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function14)
 */
default Tuple14Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> withSideEffect(Function14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6(), tuple._7(), tuple._8(), tuple._9(), tuple._10(), tuple._11(), tuple._12(), tuple._13(), tuple._14())));
}

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code withSideEffect("sideEffect", func)}.
 * @see #withSideEffect(String, Function15)
 */
default Tuple15Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> withSideEffect(Function15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, Task<?>> func) {
 return cast(Task.super.withSideEffect("sideEffect: " + _taskDescriptor.getDescription(func.getClass().getName()), tuple -> func.apply(tuple._1(), tuple._2(), tuple._3(), tuple._4(), tuple._5(), tuple._6(), tuple._7(), tuple._8(), tuple._9(), tuple._10(), tuple._11(), tuple._12(), tuple._13(), tuple._14(), tuple._15())));
}

代码示例来源:origin: linkedin/parseq

@Test
public void testSideEffectsPredecessorTrace() throws InterruptedException, IOException {
 final Task<String> baseTask = value("base", "baseValue");
 final Task<String> sideEffect = value("sideEffect", "sideEffectValue");
 final Task<String> withSideEffect = baseTask.withSideEffect(x -> sideEffect);
 runAndWait("TestTaskToTrace.testSideEffectsPredecessorTrace", withSideEffect);
 assertTrue(sideEffect.await(5, TimeUnit.SECONDS));
 assertEquals(2, getRelationships(withSideEffect.getTrace(), withSideEffect.getId()).size());
 verifyShallowTrace(sideEffect);
 verifyShallowTrace(baseTask);
 assertTrue(withSideEffect.getTrace().getRelationships().toString(), withSideEffect.getTrace().getRelationships()
   .contains(new TraceRelationship(withSideEffect.getShallowTraceBuilder(),
     baseTask.getShallowTraceBuilder(), Relationship.PARENT_OF)));
}

相关文章