// writeRetryFunc runs writeFunc with retries if required
776847
func (c *consulClientImpl) writeRetryFunc(f writeFunc) (*api.WriteMeta, error) {
	var err error
	var meta *api.WriteMeta
	retry := false
	c.runWithRetry(func() bool {
		conn := c.conn
		meta, err = f(conn)
		retry, err = c.reconnectIfConnectionError(conn, err)
		return retry
	})
	return meta, err
}
1283250
func TemporaryNetworkError(n int) RetryFunc {
	return func(err error) (retry bool, delay time.Duration) {
		var nerr net.Error
		var ok bool

		// Never retry if this is not a network error.
		switch rerr := err.(type) {
		case *url.Error:
			if nerr, ok = rerr.Err.(net.Error); !ok {
				return false, 0
			}
		case net.Error:
			nerr = rerr
		default:
			return false, 0
		}

		if !nerr.Temporary() {
			return false, 0
		}

		// Don't retry if we're out of tries.
		if n--; n <= 0 {
			return false, 0
		}

		return true, 0
	}
}
907348
func writeCopyPartErr(ctx context.Context, w http.ResponseWriter, err error, url *url.URL, browser bool) {
	switch err {
	case errInvalidRange:
		writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrInvalidCopyPartRange), url, browser)
		return
	case errInvalidRangeSource:
		writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrInvalidCopyPartRangeSource), url, browser)
		return
	default:
		writeErrorResponse(ctx, w, toAPIError(ctx, err), url, browser)
		return
	}
}
783158
func (dec *declaration) WriteTo(w io.Writer) (int64, error) {
	return dec.writeTo(w, nil)
}
1100782
func (fn ClientRequestWriterFunc) WriteToRequest(req ClientRequest, reg strfmt.Registry) error {
	return fn(req, reg)
}
1253793
func WriteTroughCacheWithNameFn(dirname string, fn func(string) string) Cache {
	return &writeTroughCache{
		memory: MemoryCache(),
		file:   FileCacheWithNameFn(dirname, fn),
	}
}
818691
func (mw *GinJWTMiddleware) MiddlewareFunc() gin.HandlerFunc {
	return func(c *gin.Context) {
		mw.middlewareImpl(c)
	}
}
604338
func (w *Writer) WriteWithPriority(p Priority, b []byte) (int, error) {
	return w.writeAndRetryWithPriority(p, string(b))
}
477520
func (mw *JWTMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc {

	if mw.Realm == "" {
		log.Fatal("Realm is required")
	}
	if mw.SigningAlgorithm == "" {
		mw.SigningAlgorithm = "HS256"
	}
	if mw.Key == nil {
		log.Fatal("Key required")
	}
	if mw.Timeout == 0 {
		mw.Timeout = time.Hour
	}
	if mw.Authenticator == nil {
		log.Fatal("Authenticator is required")
	}
	if mw.Authorizator == nil {
		mw.Authorizator = func(userId string, request *rest.Request) bool {
			return true
		}
	}

	return func(writer rest.ResponseWriter, request *rest.Request) { mw.middlewareImpl(writer, request, handler) }
}
62811
func WithErrorWriter(e io.Writer) OptFunc {
	return func(c *RWI) {
		if e != nil {
			c.errorWriter = e
		}
	}
}
500111
func (c *Characteristic) HandleWriteFunc(f func(r Request, data []byte) (status byte)) {
	c.HandleWrite(WriteHandlerFunc(f))
}
1038973
func (s *Store) WriteRemote(remote *Remote) error {
	err := s.db.Do(func(tx *sql.Tx) error {
		return WriteRemote(tx, remote)
	})
	return err
}
13911
func SafeWriteToFile(g SafeWriteLogger, t SafeWriter, mode os.FileMode) error {
	return safeWriteToFileOnce(g, t, mode)
}
525748
func (a *Application) Writer(w io.Writer) *Application {
	a.errorWriter = w
	a.usageWriter = w
	return a
}
1166831
func gocairoWriteFunc(key C.int, data unsafe.Pointer, clength C.uint) bool {
	writeClosure := goPointers.get(key).(writeClosure)
	length := uint(clength)
	slice := ((*[1 << 30]byte)(data))[:length:length]
	_, writeClosure.err = writeClosure.w.Write(slice)
	return writeClosure.err == nil
}
1011729
func writeSync(pipe io.Writer, sync syncType) error {
	return utils.WriteJSON(pipe, syncT{sync})
}
280855
func (ctx *WriterContext) Writef(format string, args ...interface{}) error {
	_, err := fmt.Fprintf(ctx.writer, format, args...)
	return err
}