Documentation ¶
Overview ¶
Package frodo implements a high-level Go wrapper to perform file read/write operations using liburing.
It exposes 2 very simple ReadFile and WriteFile functions which are akin to the ioutil family of functions. These calls just push an entry to the submission queue. To allow the user to control when to submit the queue, a Poll function is provided. The Poll function will submit the queue and wait for all the entries to appear in the completion queue.
Example ¶
package main import ( "fmt" "sync" "github.com/agnivade/frodo" ) func main() { err := frodo.Init() if err != nil { fmt.Println(err) return } defer frodo.Cleanup() go func() { for err := range frodo.Err() { fmt.Println(err) } }() var wg sync.WaitGroup // Read a file. err = frodo.ReadFile("testdata/ssa.html", func(buf []byte) { defer wg.Done() // handle buf }) if err != nil { fmt.Println(err) return } // Write something err = frodo.WriteFile("testdata/dummy.txt", []byte("hello world"), 0644, func(n int) { defer wg.Done() // handle n }) // Call Poll to let the kernel know to read the entries. frodo.Poll() // Wait till all callbacks are done. wg.Wait() }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Err ¶
func Err() <-chan error
Err is a channel that needs to be read to receive internal errors that can happen during interaction with the ring or during callbacks. It must be read from after calling Init, otherwise the processing might get stuck.
func Poll ¶
func Poll()
Poll signals the kernel to read all pending entries from the submission queue and waits until all entries have been read from the completion queue.
Types ¶
This section is empty.