reaper

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2014 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package reaper provides a reaper which checks and removes expired sessions periodically.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Quit

func Quit(quitC chan<- struct{}, doneC <-chan struct{})

Quit terminates the reap goroutine.

func Run

func Run(db *bolt.DB, options Options) (chan<- struct{}, <-chan struct{})

Run invokes a reap function as a goroutine.

Example
// Open a Bolt database.
db, err := bolt.Open("./sessions.db", 0666)
if err != nil {
	panic(err)
}

// Close the database when the current function ends.
defer db.Close()

// Invoke a reaper which checks and removes expired sessions periodically.
// Terminate the reaper when the current function ends.
defer Quit(Run(db, Options{}))
Output:

Types

type Options

type Options struct {
	// BucketName represents the name of the bucket which contains sessions.
	BucketName []byte
	// BatchSize represents the maximum number of sessions which the reaper
	// process at one time.
	BatchSize int
	// CheckInterval represents the interval between the reaper's invocation.
	CheckInterval time.Duration
}

Options represents options for the reaper.

Jump to

Keyboard shortcuts

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