archive

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package archive provides a generic system to create archive api services.

This package is a work in progress and makes no API stability promises.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterBackendBuilder

func RegisterBackendBuilder(class string, builder BuildBackendFn)

RegisterBackendBuilder registers a builder.

func RegisterServiceBuilder

func RegisterServiceBuilder(class string, builder BuildServiceFn)

RegisterServiceBuilder registers a builder.

Types

type API

type API int

API stores archive APIs available.

const (
	EventAPI API = iota
	DNSAPI
	TLSAPI
)

List of valid archive APIs.

type Backend

type Backend interface {
	ID() string
	Class() string
	Session() interface{}
	Ping() error
}

Backend interface is a container that stores backend information.

type BackendDef

type BackendDef struct {
	// ID must exist and be unique
	ID string `json:"id"`
	// Class stores the driver
	Class string `json:"class"`
	// Disabled flag
	Disabled bool `json:"disabled"`
	// Name or description
	Name string `json:"name,omitempty"`
	// URL provides the url to backend
	URL string `json:"url,omitempty"`
	// Client configuration
	Client *grpctls.ClientCfg `json:"tls,omitempty"`
	// Opts custom options
	Opts map[string]interface{} `json:"opts,omitempty"`
}

BackendDef stores configuration definition of backends.

func BackendDefsFromFile

func BackendDefsFromFile(path string) ([]BackendDef, error)

BackendDefsFromFile creates a slice from a file in json format.

func (BackendDef) ClientCfg

func (def BackendDef) ClientCfg() grpctls.ClientCfg

ClientCfg returns a copy of client configuration. It returns an empty struct if a null pointer is stored.

type BuildBackendFn

type BuildBackendFn func(b *Builder, def BackendDef) (Backend, error)

BuildBackendFn defines a function that constructs a Backend.

type BuildServiceFn

type BuildServiceFn func(b *Builder, def ServiceDef) (Service, error)

BuildServiceFn defines a function that constructs a Service.

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder constructs backends and services from definitions.

func NewBuilder

func NewBuilder(opt ...BuilderOption) *Builder

NewBuilder instances a new builder.

func (*Builder) Backend

func (b *Builder) Backend(id string) (Backend, bool)

Backend returns the Backend with the id.

func (*Builder) BuildBackend

func (b *Builder) BuildBackend(def BackendDef) (Backend, error)

BuildBackend creates a Backend using the definition passed as param.

func (*Builder) BuildService

func (b *Builder) BuildService(def ServiceDef) (Service, error)

BuildService creates a Service using the definition passed as param.

func (Builder) Logger

func (b Builder) Logger() yalogi.Logger

Logger returns logger.

func (*Builder) OnShutdown

func (b *Builder) OnShutdown(f func() error)

OnShutdown registers the functions that will be executed during shutdown.

func (*Builder) OnStartup

func (b *Builder) OnStartup(f func() error)

OnStartup registers the functions that will be executed during startup.

func (*Builder) PingAll

func (b *Builder) PingAll() error

PingAll backends.

func (*Builder) Service

func (b *Builder) Service(id string) (Service, bool)

Service returns the Service with the id.

func (*Builder) Shutdown

func (b *Builder) Shutdown() error

Shutdown executes all registered functions.

func (*Builder) Start

func (b *Builder) Start() error

Start executes all registered functions.

type BuilderOption

type BuilderOption func(*buildOpts)

BuilderOption is used for builder configuration.

func SetLogger

func SetLogger(l yalogi.Logger) BuilderOption

SetLogger sets a logger for the component.

type Service

type Service interface {
	ID() string
	Class() string
	Implements() []API
}

Service interface for archive services.

type ServiceDef

type ServiceDef struct {
	// ID must exist and be unique
	ID string `json:"id"`
	// Class stores the services class
	Class string `json:"class"`
	// Disabled flag
	Disabled bool `json:"disabled"`
	// Name or description
	Name string `json:"name,omitempty"`
	// Backend ID
	Backend string `json:"backend,omitempty"`
	// Opts custom options
	Opts map[string]interface{} `json:"opts,omitempty"`
}

ServiceDef stores configuration definition of services.

func ServiceDefsFromFile

func ServiceDefsFromFile(path string) ([]ServiceDef, error)

ServiceDefsFromFile creates a slice from a file in json format.

Directories

Path Synopsis
backends
services
dnsmdb
Package dnsmdb implements dnsutil.Archive using mongodb backend.
Package dnsmdb implements dnsutil.Archive using mongodb backend.
eventmdb
Package eventmdb implements event.Archive using mongodb backend.
Package eventmdb implements event.Archive using mongodb backend.
tlsmdb
Package tlsmdb implements tlsutil.Archive using mongodb backend.
Package tlsmdb implements tlsutil.Archive using mongodb backend.

Jump to

Keyboard shortcuts

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