当前位置: 首页>>代码示例>>Golang>>正文


Golang ifrit.Process类代码示例

本文整理汇总了Golang中github.com/tedsuo/ifrit.Process的典型用法代码示例。如果您正苦于以下问题:Golang Process类的具体用法?Golang Process怎么用?Golang Process使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Process类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: forwardSignals

func forwardSignals(signals <-chan os.Signal, process ifrit.Process) {
	exit := process.Wait()
	for {
		select {
		case sig := <-signals:
			process.Signal(sig)
		case <-exit:
			return
		}
	}
}
开发者ID:qinguoan,项目名称:vulcan,代码行数:11,代码来源:proxy.go

示例2: waitUntilReady

func waitUntilReady(process ifrit.Process, logger lager.Logger) error {
	//we could not find a reliable way for ifrit to report that all processes
	//were ready without error, so we opted to simply report as ready if no errors
	//were thrown within a timeout
	ready := time.After(5 * time.Second)
	select {
	case <-ready:
		logger.Info("All child processes are ready")
		return nil
	case err := <-process.Wait():
		if err == nil {
			//sometimes process will exit early, but will return a nil error
			err = errors.New("Child process exited before becoming ready")
		}
		return err
	}
}
开发者ID:cautio,项目名称:switchboard,代码行数:17,代码来源:main.go

示例3: waitForEvents

func waitForEvents(
	member Member,
	process ifrit.Process,
	entrance entranceEventChannel,
	exit exitEventChannel,
) {
	select {
	case <-process.Ready():
		entrance <- EntranceEvent{
			Member:  member,
			Process: process,
		}

		exit <- ExitEvent{
			Member: member,
			Err:    <-process.Wait(),
		}

	case err := <-process.Wait():
		entrance <- EntranceEvent{
			Member:  member,
			Process: process,
		}

		exit <- ExitEvent{
			Member: member,
			Err:    err,
		}
	}
}
开发者ID:qinguoan,项目名称:vulcan,代码行数:30,代码来源:dynamic_group.go

示例4:

		attempt3Factory = new(fakes.FakeStepFactory)
		attempt3Step = new(fakes.FakeStep)
		attempt3Factory.UsingReturns(attempt3Step)

		stepFactory = Retry{attempt1Factory, attempt2Factory, attempt3Factory}
		step = stepFactory.Using(nil, nil)
	})

	Context("when attempt 1 succeeds", func() {
		BeforeEach(func() {
			attempt1Step.ResultStub = successResult(true)
		})

		Describe("Run", func() {
			var process ifrit.Process

			JustBeforeEach(func() {
				process = ifrit.Invoke(step)
			})

			It("returns nil having only run the first attempt", func() {
				Expect(<-process.Wait()).ToNot(HaveOccurred())

				Expect(attempt1Step.RunCallCount()).To(Equal(1))
				Expect(attempt2Step.RunCallCount()).To(Equal(0))
				Expect(attempt3Step.RunCallCount()).To(Equal(0))
			})

			Describe("Result", func() {
				It("delegates to attempt 1", func() {
开发者ID:pcfdev-forks,项目名称:atc,代码行数:30,代码来源:retry_test.go

示例5:

	"github.com/pivotal-golang/clock/fakeclock"

	"github.com/cloudfoundry-incubator/converger/converger_process"
)

const aBit = 100 * time.Millisecond

var _ = Describe("ConvergerProcess", func() {
	var (
		fakeBBSServiceClient        *fake_bbs.FakeServiceClient
		fakeBBSClient               *fake_bbs.FakeClient
		logger                      *lagertest.TestLogger
		fakeClock                   *fakeclock.FakeClock
		convergeRepeatInterval      time.Duration
		kickTaskDuration            time.Duration
		expirePendingTaskDuration   time.Duration
		expireCompletedTaskDuration time.Duration

		process ifrit.Process

		waitEvents chan<- models.CellEvent
		waitErrs   chan<- error
	)

	BeforeEach(func() {
		fakeBBSServiceClient = new(fake_bbs.FakeServiceClient)
		fakeBBSClient = new(fake_bbs.FakeClient)
		logger = lagertest.NewTestLogger("test")
		fakeClock = fakeclock.NewFakeClock(time.Now())

		convergeRepeatInterval = 1 * time.Second
开发者ID:emc-xchallenge,项目名称:converger,代码行数:31,代码来源:converger_process_test.go

示例6:

	"code.cloudfoundry.org/lager/lagertest"

	"github.com/nats-io/nats"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/tedsuo/ifrit"
)

var _ = Describe("Subscriber", func() {
	var (
		sub     *mbus.Subscriber
		subOpts *mbus.SubscriberOpts
		process ifrit.Process

		registry *fakes.FakeRegistryInterface

		natsRunner   *test_util.NATSRunner
		natsPort     uint16
		natsClient   *nats.Conn
		startMsgChan chan struct{}

		logger lager.Logger
	)

	BeforeEach(func() {
		natsPort = test_util.NextAvailPort()

		natsRunner = test_util.NewNATSRunner(int(natsPort))
		natsRunner.Start()
		natsClient = natsRunner.MessageBus

		registry = new(fakes.FakeRegistryInterface)
开发者ID:cloudfoundry,项目名称:gorouter,代码行数:32,代码来源:subscriber_test.go

示例7:

		fakeWorkerClient = new(wfakes.FakeClient)

		factory = NewGardenFactory(fakeWorkerClient, fakeTracker, func() string { return "" })

		stdoutBuf = gbytes.NewBuffer()
		stderrBuf = gbytes.NewBuffer()
	})

	Describe("DependentGet", func() {
		var (
			getDelegate    *fakes.FakeGetDelegate
			resourceConfig atc.ResourceConfig
			params         atc.Params
			version        atc.Version
			tags           []string

			inStep *fakes.FakeStep
			repo   *SourceRepository

			step    Step
			process ifrit.Process
		)

		BeforeEach(func() {
			getDelegate = new(fakes.FakeGetDelegate)
			getDelegate.StdoutReturns(stdoutBuf)
			getDelegate.StderrReturns(stderrBuf)

			resourceConfig = atc.ResourceConfig{
				Name:   "some-resource",
				Type:   "some-resource-type",
开发者ID:savaki,项目名称:atc,代码行数:31,代码来源:dependent_get_step_test.go

示例8:

		handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			startedRequestChan <- struct{}{}
			<-finishRequestChan
			w.Write([]byte("yo"))
		})
	)

	BeforeEach(func() {
		startedRequestChan = make(chan struct{}, 1)
		finishRequestChan = make(chan struct{}, 1)
		port := 8000 + GinkgoParallelNode()
		address = fmt.Sprintf("127.0.0.1:%d", port)
	})

	Describe("Invoke", func() {
		var process ifrit.Process
		var socketPath string

		Context("when the server is started with a different net Protocol.", func() {
			var tmpdir string

			BeforeEach(func() {
				unixHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
					w.Write([]byte("yo"))
				})
				var err error
				tmpdir, err = ioutil.TempDir(os.TempDir(), "ifrit-server-test")
				Ω(err).ShouldNot(HaveOccurred())

				socketPath = path.Join(tmpdir, "ifrit.sock")
				Ω(err).ShouldNot(HaveOccurred())
开发者ID:cloudfoundry-incubator,项目名称:routing-perf-release,代码行数:31,代码来源:http_server_test.go

示例9:

	"github.com/concourse/atc"
	. "github.com/concourse/atc/resource"
	"github.com/concourse/atc/resource/fakes"
)

var _ = Describe("Resource Out", func() {
	var (
		source             atc.Source
		params             atc.Params
		fakeArtifactSource *fakes.FakeArtifactSource

		outScriptStdout     string
		outScriptStderr     string
		outScriptExitStatus int
		runOutError         error

		outScriptProcess *gfakes.FakeProcess

		versionedSource VersionedSource
		outProcess      ifrit.Process

		ioConfig  IOConfig
		stdoutBuf *gbytes.Buffer
		stderrBuf *gbytes.Buffer
	)

	BeforeEach(func() {
		source = atc.Source{"some": "source"}
		params = atc.Params{"some": "params"}
		fakeArtifactSource = new(fakes.FakeArtifactSource)
开发者ID:utako,项目名称:atc,代码行数:30,代码来源:resource_out_test.go

示例10:

	"github.com/tedsuo/ifrit"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

// a bit of grace time for eventuallys
const aBit = 50 * time.Millisecond

var _ = Describe("PeriodicMetronNotifier", func() {
	var (
		sender *fake.FakeMetricSender

		etcdOptions    etcd.ETCDOptions
		reportInterval time.Duration
		fakeClock      *fakeclock.FakeClock

		pmn ifrit.Process
	)

	BeforeEach(func() {
		reportInterval = 100 * time.Millisecond

		fakeClock = fakeclock.NewFakeClock(time.Unix(123, 456))

		sender = fake.NewFakeMetricSender()
		dropsonde_metrics.Initialize(sender, nil)
	})

	JustBeforeEach(func() {
开发者ID:emc-xchallenge,项目名称:bbs,代码行数:31,代码来源:periodic_metron_notifier_test.go

示例11:

	"fmt"
	"os"
	"time"

	. "github.com/cloudfoundry/gunk/diegonats"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/pivotal-golang/lager/lagertest"

	"github.com/tedsuo/ifrit"
)

var _ = Describe("Starting the NatsClientRunner process", func() {
	var natsClient NATSClient
	var natsClientRunner ifrit.Runner
	var natsClientProcess ifrit.Process

	BeforeEach(func() {
		natsAddress := fmt.Sprintf("127.0.0.1:%d", natsPort)
		natsClient = NewClient()
		natsClientRunner = NewClientRunner(natsAddress, "nats", "nats", lagertest.NewTestLogger("test"), natsClient)
	})

	AfterEach(func() {
		stopNATS()
		if natsClientProcess != nil {
			natsClientProcess.Signal(os.Interrupt)
			Eventually(natsClientProcess.Wait(), 5).Should(Receive())
		}
	})
开发者ID:glyn,项目名称:gunk,代码行数:30,代码来源:nats_client_runner_test.go

示例12:

	"syscall"
	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/fake_runner"
	"github.com/tedsuo/ifrit/grouper"
)

var _ = Describe("dynamicGroup", func() {
	var (
		client      grouper.DynamicClient
		pool        grouper.DynamicGroup
		poolProcess ifrit.Process

		childRunner1 *fake_runner.TestRunner
		childRunner2 *fake_runner.TestRunner
		childRunner3 *fake_runner.TestRunner
	)

	BeforeEach(func() {
		childRunner1 = fake_runner.NewTestRunner()
		childRunner2 = fake_runner.NewTestRunner()
		childRunner3 = fake_runner.NewTestRunner()
	})
	AfterEach(func() {
		childRunner1.EnsureExit()
		childRunner2.EnsureExit()
		childRunner3.EnsureExit()
	})
开发者ID:nagyistoce,项目名称:lattice-app,代码行数:31,代码来源:dynamic_group_test.go

示例13:

	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"
	"github.com/nats-io/nats"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/tedsuo/ifrit"
)

var _ = Describe("Router", func() {
	var (
		logger     lager.Logger
		natsRunner *test_util.NATSRunner
		config     *cfg.Config
		p          proxy.Proxy

		mbusClient  *nats.Conn
		registry    *rregistry.RouteRegistry
		varz        vvarz.Varz
		rtr         *router.Router
		subscriber  ifrit.Process
		natsPort    uint16
		healthCheck int32
	)

	testAndVerifyRouterStopsNoDrain := func(signals chan os.Signal, closeChannel chan struct{}, sigs ...os.Signal) {
		app := common.NewTestApp([]route.Uri{"drain.vcap.me"}, config.Port, mbusClient, nil, "")
		blocker := make(chan bool)
		resultCh := make(chan bool, 2)
		app.AddHandler("/", func(w http.ResponseWriter, r *http.Request) {
			blocker <- true

			_, err := ioutil.ReadAll(r.Body)
开发者ID:cloudfoundry,项目名称:gorouter,代码行数:32,代码来源:router_drain_test.go

示例14: Kill

func Kill(process ifrit.Process, intervals ...interface{}) {
	if process != nil {
		process.Signal(os.Kill)
		Eventually(process.Wait(), intervals...).Should(Receive(), "killed ginkgomon process failed to exit in time")
	}
}
开发者ID:trainchou,项目名称:gorouter,代码行数:6,代码来源:helpers.go

示例15: Interrupt

func Interrupt(process ifrit.Process, intervals ...interface{}) {
	process.Signal(os.Interrupt)
	Eventually(process.Wait(), intervals...).Should(Receive(), "interrupted ginkgomon process failed to exit in time")
}
开发者ID:trainchou,项目名称:gorouter,代码行数:4,代码来源:helpers.go


注:本文中的github.com/tedsuo/ifrit.Process类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。