Example #1
0
func NewDropOp() *mapper.Op {
	dropfn := func(input stream.Object, out mapper.Outputer) error {
		return nil
	}

	return mapper.NewOp(dropfn, "DropOp")
}
Example #2
0
func NewPassthruOp() *mapper.Op {
	fn := func(input stream.Object, out mapper.Outputer) error {
		out.Sending(1).Send(input)
		return nil
	}

	return mapper.NewOp(fn, "PassthruOp")
}
Example #3
0
func TestNoOrder(t *testing.T) {

	input := make(chan stream.Object)

	passthruFn := func(obj stream.Object, out mapper.Outputer) {
		out.Sending(1).Send(obj)
	}

	FirstOp := mapper.NewOp(passthruFn, "First PT no")
	FirstOp.SetIn(input)
	SecondOp := mapper.NewOp(passthruFn, "2nd PT no")

	ch := stream.NewChain()
	ch.Add(FirstOp)
	ch.Add(SecondOp)

	output := SecondOp.Out()
	ch.Start()

	go func() {
		for i := 0; i < 10000; i++ {
			input <- i
		}
	}()

	found := false
	for i := 0; i < 10000; i++ {
		val := <-output
		if val != i {
			found = true
		}
	}

	if !found {
		t.Error("Weird no out of order stuff found")
	}
	ch.Stop()
	ch.Wait()
}