コード例 #1
0
ファイル: adaptors.go プロジェクト: influx6/dataquery
// ChunkParser returns a Reactor that combines the ChunkScanAdaptor with the ParseAdaptor to allow stringed queries
func ChunkParser(ds *parser.InspectionFactory) flux.Reactor {
	ms := flux.ReactorStack()

	ms.Bind(ChunkScanAdaptor(), true)
	ms.Bind(ParseAdaptor(ds), true)
	return ms
}
コード例 #2
0
ファイル: builders.go プロジェクト: influx6/reactors
// BinaryBuildLauncher combines the builder and binary runner to provide a simple and order-based process,
// the BinaryLauncher is only created to handling a binary lunching making it abit of a roundabout to time its response to wait until another process finishes, but BinaryBuildLuncher cleans out the necessity and provides a reactor that embedds the necessary call routines while still response the: Build->Run or StopRunning->Build->Run process in development
func BinaryBuildLauncher(cmd BinaryBuildConfig) flux.Reactor {
	validateBinaryBuildConfig(cmd)

	// first generate the output file name from the config
	var basename = cmd.Name

	if runtime.GOOS == "windows" {
		basename = fmt.Sprintf("%s.exe", basename)
	}

	binfile := filepath.Join(cmd.Path, basename)

	//create the root stack which connects all the sequence of build and run together
	buildStack := flux.ReactorStack()

	//package builder
	builder := GoBuilderWith(BuildConfig{Path: cmd.Path, Name: cmd.Name, Args: cmd.BuildArgs})

	//package runner
	runner := BinaryLauncher(binfile, cmd.RunArgs)

	//when buildStack receives a signal, we will send a bool(false) signal to runner to kill the current process
	buildStack.React(flux.SimpleMuxer(func(root flux.Reactor, data interface{}) {
		//tell runner to kill process
		// log.Printf("sending to runner")
		runner.Send(false)
		//forward the signal down the chain
		root.Reply(data)
	}), true)

	//connect the build stack first then the runn stack to force order
	buildStack.Bind(builder, true)
	buildStack.Bind(runner, true)

	return buildStack
}