// RunRecorder =========================
773365
func newRunRecorder(c *Context) (empire.RunRecorder, error) {
	backend := c.String(FlagRunLogsBackend)
	switch backend {
	case "cloudwatch":
		group := c.String(FlagCloudWatchLogGroup)

		log.Println("Using CloudWatch run logs backend with the following configuration:")
		log.Println(fmt.Sprintf("  LogGroup: %s", group))

		return logs.RecordToCloudWatch(group, c), nil
	case "stdout":
		log.Println("Using Stdout run logs backend")
		return logs.RecordTo(os.Stdout), nil
	default:
		panic(fmt.Sprintf("unknown run logs backend: %v", backend))
	}
}
754304
func (s *Subscription) run() error {
	if s.active {
		return nil
	}

	go func() {
		for {
			select {
			case e := <-s.eventChannel:
				if e.Status != "" {
					s.lock.RLock()
					h, ok := s.handlers[e.Status]
					if ok {
						h(e)
					}
					s.lock.RUnlock()
				}
			case crc := <-s.cancelChannel:
				crc <- struct{}{}
				return
			case <-s.monitorDone:
				s.active = false
				return
			}
		}
	}()

	s.active = true
	return nil
}
1296162
func (s *Source) Record() (interface{}, error) {
	next := atomic.AddUint64(s.n, 1)
	if next > s.max {
		close(s.closed)
		s.wg.Wait()
		return nil, io.EOF
	}
	return <-s.events, nil
}
433627
func (rp *Reprovider) Run(tick time.Duration) {
	// dont reprovide immediately.
	// may have just started the daemon and shutting it down immediately.
	// probability( up another minute | uptime ) increases with uptime.
	after := time.After(time.Minute)
	var done doneFunc
	for {
		if tick == 0 {
			after = make(chan time.Time)
		}

		select {
		case <-rp.ctx.Done():
			return
		case done = <-rp.trigger:
		case <-after:
		}

		//'mute' the trigger channel so when `ipfs bitswap reprovide` is called
		//a 'reprovider is already running' error is returned
		unmute := rp.muteTrigger()

		err := rp.Reprovide()
		if err != nil {
			log.Debug(err)
		}

		if done != nil {
			done(err)
		}

		unmute()

		after = time.After(tick)
	}
}
727768
func NewRecorder(w Interface) *Recorder {
	r := &Recorder{}
	r.Interface = Filter(w, r.record)
	return r
}
1243803
func (fer *FirstErrorRecorder) Error() error {
	fer.mu.Lock()
	defer fer.mu.Unlock()
	return fer.firstError
}
663174
func RecordTo(w io.Writer) empire.RunRecorder {
	return func() (io.Writer, error) {
		return w, nil
	}
}
667849
func recordError(operation string, err error) {
	if err != nil {
		metrics.RuntimeOperationsErrors.WithLabelValues(operation).Inc()
		metrics.DeprecatedRuntimeOperationsErrors.WithLabelValues(operation).Inc()
	}
}
1069915
func (s *Source) Record() (rec interface{}, err error) {
	var res map[string]interface{}
	err = s.dec.Decode(&res)
	if err != nil {
		return nil, err
	}
	return res, nil
}
440879
func (mr *MockAgentClientMockRecorder) RunScript(scriptName, options interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunScript", reflect.TypeOf((*MockAgentClient)(nil).RunScript), scriptName, options)
}
361167
func recordTryError(try *parallel.Try, err error) {
	logger.Infof("%v", err)
	try.Start(func(_ <-chan struct{}) (io.Closer, error) {
		return nil, errors.Trace(err)
	})
}
988602
func RecordTrace(w io.Writer, trace *RequestTrace) {
	attempt := AttemptReport{
		Reused:     trace.Reused,
		Latency:    trace.Finish.Sub(trace.Start),
		ReqWritten: trace.RequestWritten.Sub(trace.Start),
	}

	if !trace.FirstResponseByte.IsZero() {
		attempt.RespFirstByte = trace.FirstResponseByte.Sub(trace.Start)
		attempt.WaitRespFirstByte = trace.FirstResponseByte.Sub(trace.RequestWritten)
	}

	if !trace.Reused {
		attempt.DNSStart = trace.DNSStart.Sub(trace.Start)
		attempt.DNSDone = trace.DNSDone.Sub(trace.Start)
		attempt.DNS = trace.DNSDone.Sub(trace.DNSStart)

		attempt.ConnectStart = trace.ConnectStart.Sub(trace.Start)
		attempt.ConnectDone = trace.ConnectDone.Sub(trace.Start)
		attempt.Connect = trace.ConnectDone.Sub(trace.ConnectStart)

		attempt.TLSHandshakeStart = trace.TLSHandshakeStart.Sub(trace.Start)
		attempt.TLSHandshakeDone = trace.TLSHandshakeDone.Sub(trace.Start)
		attempt.TLSHandshake = trace.TLSHandshakeDone.Sub(trace.TLSHandshakeStart)
	}

	_, err := fmt.Fprintln(w,
		"Latency:",
		attempt.Latency,

		"ConnectionReused:",
		fmt.Sprintf("%t", attempt.Reused),

		"DNSStartAt:",
		fmt.Sprintf("%s", attempt.DNSStart),
		"DNSDoneAt:",
		fmt.Sprintf("%s", attempt.DNSDone),
		"DNSDur:",
		fmt.Sprintf("%s", attempt.DNS),

		"ConnectStartAt:",
		fmt.Sprintf("%s", attempt.ConnectStart),
		"ConnectDoneAt:",
		fmt.Sprintf("%s", attempt.ConnectDone),
		"ConnectDur:",
		fmt.Sprintf("%s", attempt.Connect),

		"TLSStatAt:",
		fmt.Sprintf("%s", attempt.TLSHandshakeStart),
		"TLSDoneAt:",
		fmt.Sprintf("%s", attempt.TLSHandshakeDone),
		"TLSDur:",
		fmt.Sprintf("%s", attempt.TLSHandshake),

		"RequestWritten",
		fmt.Sprintf("%s", attempt.ReqWritten),
		"RespFirstByte:",
		fmt.Sprintf("%s", attempt.RespFirstByte),
		"WaitRespFirstByte:",
		fmt.Sprintf("%s", attempt.WaitRespFirstByte),
	)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to write request trace, %v\n", err)
	}
}
243054
func (mr *MockImplementorMockRecorder) Run(ctx interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockImplementor)(nil).Run), ctx)
}
985236
func (c *Client) PutRecord(request PutRecordRequest) (*PutRecordResponse, error) {
	resp := &PutRecordResponse{}
	err := c.kinesisReqWithResponse("PutRecord", request, resp)
	return resp, err
}
1210617
func NewRecordGenerator(options ...Option) *RecordGenerator {
	rg := &RecordGenerator{}
	rg.stateLoader = func(_ []string) (s state.State, err error) { return }
	for i := range options {
		if options[i] != nil {
			options[i](rg)
		}
	}
	return rg
}
919246
func (a *Archiver) RunOnce(ctx context.Context) error {
	if a.Source == nil {
		return errors.New("archiver: nil Source")
	}
	if a.Store == nil {
		return errors.New("archiver: nil Store func")
	}
	pz := &potentialZip{a: a}
	err := blobserver.EnumerateAll(ctx, a.Source, func(sb blob.SizedRef) error {
		if err := pz.addBlob(ctx, sb); err != nil {
			return err
		}
		if pz.bigEnough() {
			return errStopEnumerate
		}
		return nil
	})
	if err == errStopEnumerate {
		err = nil
	}
	if err != nil {
		return err
	}
	if err := pz.condClose(); err != nil {
		return err
	}
	if !pz.bigEnough() {
		return ErrSourceTooSmall
	}
	if err := a.Store(pz.buf.Bytes(), pz.blobs); err != nil {
		return err
	}
	if a.DeleteSourceAfterStore {
		blobs := make([]blob.Ref, 0, len(pz.blobs))
		for _, sb := range pz.blobs {
			blobs = append(blobs, sb.Ref)
		}
		if err := a.Source.RemoveBlobs(ctx, blobs); err != nil {
			return err
		}
	}
	return nil
}
772397
func (d *frameDec) runDecoder(dst []byte, dec *blockDec) ([]byte, error) {
	// TODO: Init to dictionary
	d.history.reset()
	saved := d.history.b

	// We use the history for output to avoid copying it.
	d.history.b = dst
	// Store input length, so we only check new data.
	crcStart := len(dst)
	var err error
	for {
		err = dec.reset(d.rawInput, d.WindowSize)
		if err != nil {
			break
		}
		if debug {
			println("next block:", dec)
		}
		err = dec.decodeBuf(&d.history)
		if err != nil || dec.Last {
			break
		}
		if uint64(len(d.history.b)) > d.o.maxDecodedSize {
			err = ErrDecoderSizeExceeded
			break
		}
	}
	dst = d.history.b
	if err == nil {
		if d.HasCheckSum {
			var n int
			n, err = d.crc.Write(dst[crcStart:])
			if err == nil {
				if n != len(dst)-crcStart {
					err = io.ErrShortWrite
				}
			}
			err = d.checkCRC()
		}
	}
	d.history.b = saved
	return dst, err
}