badger

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

README

constructor-badger - Constructor wrapper for badger

codecov Build Status GoDoc

Quick Start

package main

import (
    "context"

    "google.golang.org/grpc"

    "github.com/stackopsd/config"
    "github.com/stackopsd/constructor"
    cbadger "github.com/stackopsd/constructor-badger"
)

func main() {
    ctx, cancel := context.WithCancel(context.Background())
    defer cancel()

    cons := cbadger.NewConstructor()
    db := new(badger.DB)

    // Create a loader from a source of configuration data.
    loader := config.NewFileLoader("/path/to/some/config.json_or_yaml")

    if err := constructor.New(ctx, loader, &cons, db); err != nil {
        panic(err)
    }
    defer db.Close()
    go func(){
        _ = srv.Serve(srv.Listener)
    }()

    if err := constructor.New(ctx, loader, &clientConst, clientConn); err != nil {
        panic(err)
    }
    defer db.Close()

}

Example Configuration

If loading from a file, the following represents all the possible options:

path: "/path/to/db"

License

Copyright 2019 Kevin Conway

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path string
}

Config contains the settings for Badger database.

type Constructor

type Constructor struct{}

Constructor generates Badger databases.

func NewConstructor

func NewConstructor() *Constructor

NewConstructor generates a default Constructor.

func (*Constructor) New

func (c *Constructor) New(ctx context.Context, conf *Config) (*badger.DB, error)

New constructs a database.

func (*Constructor) Settings

func (c *Constructor) Settings() *Config

Settings generates the default configuration.

Jump to

Keyboard shortcuts

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