temporary

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

将io.Reader转换成io.ReadSeeker。 功能

  1. 超过一定大小、将临时缓冲转成临时文件
  2. 异步读取源信息
  3. 异步读取源信息后关闭

Attention

使用异步读取数据时候, 在调用其他方法之前一定要先使用Await。
该操作等待全部数据的加载, 同时可以处理读取数据时的错误。

Index

Constants

View Source
const (
	TemporaryBuffer string = "Buffer"
	TemporaryFile   string = "File"
)

Variables

View Source
var (
	ErrBufferTooLarge             error = fmt.Errorf("buffer too large")
	ErrBufferSeekInvalidWhence    error = fmt.Errorf("buffer seek invalid whence")
	ErrBufferSeekNegativePosition error = fmt.Errorf("buffer seek negative position")
)
View Source
var (
	ErrFileSeekInvalidWhence    error = fmt.Errorf("file seek invalid whence")
	ErrFileSeekNegativePosition error = fmt.Errorf("file seek negative position")
)

Functions

This section is empty.

Types

type Temporary

type Temporary interface {
	Await() error
	Size() int64
	Type() string
	Name() string
	Bytes() []byte
	io.Reader
	io.Seeker
	io.Closer
}

func NewAsyncTemporary

func NewAsyncTemporary(reader io.Reader, maxBufferSize int64, fileDir string, filePattern string) (_ Temporary)

func NewMustCloseReaderAsyncTemporary

func NewMustCloseReaderAsyncTemporary(readcloser io.ReadCloser, maxBufferSize int64, fileDir string, filePattern string) (_ Temporary)

func NewTemporary

func NewTemporary(reader io.Reader, maxBufferSize int64, fileDir string, filePattern string) (_ Temporary, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL