Exemple #1
0
/* A stop is a hard stop as per the Operator interface */
func (c *SimpleChain) Stop() error {
	c.stopOnce.Do(func() {
		slog.Warnf("In hard close of chain %s", c.Name)
		c.runner.HardStop()
	})
	return nil
}
Exemple #2
0
func (src *Client) Run() error {
	src.running = true
	defer func() {
		src.running = false
	}()

	metrics.Gm.Register(stream.Name(src))
	go func(op string, s *Client) { // Update the queue depth on input for each phase
		for {
			metrics.Gm.Update(&op, s.GetInDepth())
			time.Sleep(1 * time.Second)
		}
	}(stream.Name(src), src)

	for src.retries < RETRY_MAX {
		err := src.connect()
		if err == nil {
			slog.Warnf("Connection failed without error")
			return err
		} else {
			slog.Errorf("Connection failed with error, retrying: %s", err)
			time.Sleep(1 * time.Second)
		}
	}
	slog.Errorf("Connection failed retries exceeded. Leftover: %d", src.buf.Len())
	return nil //>>>>>>>>>>>>>>???????????????????????
}
Exemple #3
0
func (c *SimpleChain) SoftStop() error {
	c.stopOnce.Do(func() {
		slog.Warnf("In soft close of chain %s", c.Name)
		ops := c.runner.Operators()
		ops[0].Stop()
	})
	return nil
}
Exemple #4
0
func NewSimpleChain() *SimpleChain {
	c := &SimpleChain{runner: NewFailSilentRunner(), Name: "SimpleChain", stopOnce: sync.Once{}}

	var stopOnce sync.Once
	opCloseHandler := func(op Operator, err error) {
		stopOnce.Do(func() {
			if err != nil {
				slog.Warnf("Hard close of chain %s was triggered by op  (%v, %v). Error: %v", c.Name, op, reflect.TypeOf(op), err)
				c.Stop()
			} else {
				slog.Infof("Soft close of chain %s was triggered by op  (%v, %v).", c.Name, op, reflect.TypeOf(op))
				c.SoftStop()
			}
		})
	}

	c.runner.SetOpCloseHandler(opCloseHandler)

	return c
}