writer

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2023 FishGoddess. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchWriter added in v1.5.10

type BatchWriter struct {
	// contains filtered or unexported fields
}

BatchWriter is a writer having a buffer inside to reduce times of writing underlying writer.

func Batch added in v1.5.10

func Batch(writer io.Writer, batchSize uint64) *BatchWriter

Batch returns a new batch writer of writer with specified batchSize. Notice that batchSize must be larger than minBatchSize or a panic will happen. See minBatchSize.

func (*BatchWriter) Close added in v1.5.10

func (bw *BatchWriter) Close() error

Close syncs data and closes underlying writer if writer implements io.Closer.

func (*BatchWriter) Sync added in v1.5.10

func (bw *BatchWriter) Sync() error

Sync writes data in buffer to underlying writer if buffer has data. It's safe in concurrency.

func (*BatchWriter) Write added in v1.5.10

func (bw *BatchWriter) Write(p []byte) (n int, err error)

Write writes p to buffer and syncs data to underlying writer first if it needs.

type BufferWriter added in v1.5.10

type BufferWriter struct {
	// contains filtered or unexported fields
}

BufferWriter is a writer having a buffer inside to reduce times of writing underlying writer.

func Buffer added in v1.5.10

func Buffer(writer io.Writer, bufferSize uint64) *BufferWriter

Buffer returns a new buffer writer of writer with specified bufferSize. Notice that bufferSize must be larger than minBufferSize or a panic will happen. See minBufferSize.

func (*BufferWriter) Close added in v1.5.10

func (bw *BufferWriter) Close() error

Close syncs data and closes underlying writer if writer implements io.Closer.

func (*BufferWriter) Sync added in v1.5.10

func (bw *BufferWriter) Sync() error

Sync writes data in buffer to underlying writer if buffer has data. It's safe in concurrency.

func (*BufferWriter) Write added in v1.5.10

func (bw *BufferWriter) Write(p []byte) (n int, err error)

Write writes p to buffer and syncs data to underlying writer first if it needs.

Jump to

Keyboard shortcuts

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