pg

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: 10 Imported by: 0

Documentation

Overview

Package pg implements the dot storage for postgres 9.5+

A http server can be implemented like so:

import "github.com/dotchain/dot/ops/pg"
import "github.com/dotchain/dot/ops/nw"
dataSource := "dbname=mydb user=xyz"
store, _ := sql.New(dataSource, "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()

Index

Constants

This section is empty.

Variables

View Source
var MaxPoll = time.Minute

MaxPoll limits the maximum poll interval for the PG instance.

This is mostly to make integration tests take less time

Functions

func New

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

New returns a store connected to the provided data stource

func Setup

func Setup(dataSourceName string) error

Setup creates the tables and indices

Types

This section is empty.

Jump to

Keyboard shortcuts

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