@Test
    public void g_V_call_lambda_with_requirements() throws Exception {
        final String serviceName = "tinker.paths";

        final Map describeParams = asMap(
                "shortest", "Boolean parameter, if true, calculate shortest path",
                "longest", "Boolean parameter, if true, calculate longest path (default)");

        final TriFunction<ServiceCallContext, TraverserSet<Vertex>, Map, Iterator<Traverser.Admin<Vertex>>> lambda =
                (ctx, traverserSet, map) -> {
            final boolean shortest = (boolean) map.getOrDefault("shortest", false);
            final boolean longest = (boolean) map.getOrDefault("longest", !shortest);

            int min = Integer.MAX_VALUE;
            int max = 0;
            for (Traverser.Admin t : traverserSet) {
                final int length = t.path().size();
                min = Math.min(min, length);
                max = Math.max(max, length);
            }
            final Iterator<Traverser.Admin<Vertex>> it = traverserSet.iterator();
            while (it.hasNext()) {
                final int length = it.next().path().size();
                if (shortest && length == min || longest && length == max) {
                    // keep
                } else {
                    it.remove();
                }
            }
            return traverserSet.iterator();
        };

        graph.getServiceRegistry().registerLambdaService(serviceName)
                .addDescribeParams(describeParams)
                        .addBarrierLambda(lambda)
                                .addRequirements(TraverserRequirement.PATH);

        checkResult("{\"name\":\"tinker.paths\",\"type:[requirements]:\":{\"Barrier\":[\"PATH\"]},\"params\":"+new ObjectMapper().writeValueAsString(describeParams)+"}",
            g.call("--list").with("service", serviceName).with("verbose"));

        checkResult(2l, g.V().repeat(out()).until(outE().count().is(0)).call(serviceName).count());
        checkResult(5l, g.V().repeat(out()).until(outE().count().is(0)).call(serviceName).with("shortest").count());
        checkResult(7l, g.V().repeat(out()).until(outE().count().is(0)).call(serviceName).with("shortest").with("longest").count());

        assertArrayEquals(new String[] {
                "path[v[1], v[4], v[5]]",
                "path[v[1], v[4], v[3]]"
                }, toResultStrings(

                g.V().repeat(out()).until(outE().count().is(0)).call(serviceName).path()

        ));
    }
Services may need to specify traverser requirements.
tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphServiceTest.java