std

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

This is collection of standard storages backend.

Include each package separately to reduce number of dependencies.

It's possible to load storages by URL (if package imported) like: `Create("redis://myhost/1?key=data")`

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(rawURL string) (storages.Storage, error)

Create new storage by looking into storages registry and mapping url parameters to configuration

Example
storage, err := Create("redis://my-host")
if err != nil {
	panic(err)
}
defer storage.Close()
Output:

func Register

func Register(schema string, factoryFunc FactoryFunc)

Register new factory for defined schema with github.com/gorilla/schema mapper for query parameters

func RegisterWithMapper

func RegisterWithMapper(schema string, factoryFunc FactoryURLFunc)

Register new factory for defined schema with custom URL mapping logic

func Supported

func Supported() []string

Supported schemas that depends of imports.

Use import like `_ "github.com/reddec/storages/std/rest"`

Types

type Configuration

type Configuration interface {
	// Create new instance of storage or fail
	Create() (storages.Storage, error)
}

Plain configuration for storage. Exported field will mapped automatically

type FactoryFunc

type FactoryFunc func() Configuration

Factory function for configuration

type FactoryURLFunc

type FactoryURLFunc func(*url.URL) (storages.Storage, error)

Factory function with custom mapping

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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