fwdq

package module
v0.0.0-...-934aa89 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: MIT Imports: 12 Imported by: 0

README

go-fwdq

Package fwdq, short for forward queue, implements a type of file-based date-time-priority queue, for the Go programming language.

Elements inserted into this queue have a date-time associated with it.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-fwdq

GoDoc

Import

To import package fwdq use import code like the following:

import "github.com/reiver/go-fwdq"

Installation

To install package fwdq do the following:

GOPROXY=direct go get github.com/reiver/go-fwdq

Author

Package fwdq was written by Charles Iliya Krempeaux

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileName

func FileName(when time.Time, bytes []byte) string

FileName returns the file-name.

A forward-queue (fwdq) is a date-time-based priority-queue. Where the 'priority' is 'time'. And, in particular, the closer a 'time' is to being the current time, without being in the past.

Each element in a forward-queue (fwdq) are stored on a storate-drive in a file. The name of the file is a function of the 'time' (which is given by `when`) and the contents of the file (which is given by `bytes).`

For example, if the `time` is given by the Unix-timestamp:

4822678189205111 // == 0x11223344556677

and the contents of is:

[]byte{0xED,0x7B,0xA4,0x70,0x8E,0x54,0x46,0x5E,0x82,0x5C,0x99,0x71,0x20,0x43,0xE0,0x1C}

Then the file-name returned will be:

"fwd_unixsec-0x0011223344556677_md5-0xa0a65c3a482379943f756a083e25f63f.octet-stream"

func InsertBytes

func InsertBytes(queuePath string, when time.Time, bytes []byte) error

InsertBytes inserts a new element into the forward-queue (FWDQ).

A forward-queue (FWDQ) is a storage-drive based queue, where the elements of the queue are files in a particular directory. The directory that the forward-queue (FWDQ) is in is given by `queuePath`.

A forward-queue (FWDQ) is a priority-queue where the 'priority' is a date-time. That date-time is given by `when`.

The content of the new element to insert into the forward-queue (FWDQ) is given by `bytes`.

Example:

const queuePath string = "/path/to/queue"

var when time.Time = time.Now().Add(5 * time.Hour)

var bytes []byte = []byte("Hello world!")

err := fwdw.InsertBytes(queuePath, when, bytes)

func Pop

func Pop(queuePath string, name string) (fs.File, error)

Pop returns the element in the queue named `name`. The returned file needs to be closed.

func Top

func Top(queuePath string, minTime time.Time) ([]string, error)

Top returns all the names of all the elements in the forward-queue (FWDQ) whose 'time' is greater-than or equal to `minTime`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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