storage

package
v0.0.0-...-caf495c Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

storage

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteDir

func DeleteDir(dir string) error

DeleteDir deletes a directory from the system

func GetNumOpenFiles

func GetNumOpenFiles() int

GetNumopenFiles gets the number of OpenFiles in system

func Init

func Init()

Init initializes the storage package. Must be called before using.

func Insert

func Insert(file string, jData []byte) (uint16, int)

Insert appends a JSON encoded []byte at the end of given JSON file and reports back the line number that was written to

func MakeDir

func MakeDir(dir string) error

MakeDir creates a directory path on the system

func Read

func Read(file string, line uint16) ([]byte, int)

Read opens a file by name, then returns the data from said line.

func SetFileOpenTime

func SetFileOpenTime(t time.Duration)

SetFileOpenTime preference allows you to keep OpenFiles open for a given duration.

func SetMaxOpenFiles

func SetMaxOpenFiles(max uint16)

SetMaxOpenFiles preference sets the maximum number of OpenFile to be open. When the maximum number of OpenFile has been reached, a random OpenFile will be closed.

func ShutDown

func ShutDown()

ShutDown closes all OpenFiles and shuts the storage engine down.

func Update

func Update(file string, line uint16, jData []byte) int

Update updates JSON encoded []byte line at given index of given file

Types

type OpenFile

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

OpenFile represents a file on a disk that is open and ready for I/O

func GetOpenFile

func GetOpenFile(file string) (*OpenFile, int)

GetOpenFile

func (*OpenFile) Lines

func (f *OpenFile) Lines() int

Lines returns the number of data lines for this OpenFile

func (*OpenFile) Read

func (f *OpenFile) Read(line uint16) ([]byte, int)

Read returns the data in an OpenFile from said line.

Jump to

Keyboard shortcuts

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