bolt

package
v0.0.0-...-917641f Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package bolt implements the dot storage for files using boltdb

A http server can be implemented like so:

import "github.com/dotchain/dot/ops/bolt"
import "github.com/dotchain/dot/ops/nw"
store, _ := bolt.New("file.bolt", "instance", nil)
defer  store.Close()
handler := &nw.Handler{Store: store}
h := func(w http.ResponseWriter, req  *http.Request) {
        // Enable CORS
        w.Header().Set("Access-Control-Allow-Origin", "*")
        w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
        if req.Method == "OPTIONS" {
              return
        }
        handler.ServeHTTP(w, req)
}
http.HandleFunc("/api/", h)
http.ListenAndServe()

Concurrency

A single store instance is safe for concurrent access but the provided file is locked until the store is closed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(fileName, id string, codec nw.Codec) (ops.Store, error)

New returns a store with the file store backed by the provided filename

Types

This section is empty.

Jump to

Keyboard shortcuts

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