resource

package
v0.0.0-...-9a3fa0c Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidType   = errors.New("invalid resource type")
	ErrNotFound      = errors.New("resource not found")
	ErrInvalidParams = errors.New("invalid resource params")
)

Functions

This section is empty.

Types

type DatabaseSQL

type DatabaseSQL interface {
	Resource

	Select(tableName string, condition map[string]string) ([]map[string]string, error)
	Insert(tableName string, rows []map[string]string) error
	Delete(tableName string, condition map[string]string) (int, error)
}

type HTTPClient

type HTTPClient interface {
	Resource

	Request(method, path string, body []byte) error
	Response() (int, http.Header, []byte, error)
}

type HTTPServer

type HTTPServer interface {
	Resource

	SetResponse(requestPath string, responseCode int, responseBody []byte) error
}

type Manager

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

func NewManager

func NewManager(cfg []*config.Resource) *Manager

func (*Manager) GetDatabaseSQL

func (m *Manager) GetDatabaseSQL(resourceName string) (DatabaseSQL, error)

func (*Manager) GetHTTPClient

func (m *Manager) GetHTTPClient(resourceName string) (HTTPClient, error)

func (*Manager) GetHTTPServer

func (m *Manager) GetHTTPServer(resourceName string) (HTTPServer, error)

func (*Manager) GetQueue

func (m *Manager) GetQueue(resourceName string) (Queue, error)

func (*Manager) GetShell

func (m *Manager) GetShell(resourceName string) (Shell, error)

func (*Manager) Ready

func (m *Manager) Ready() error

func (*Manager) Reset

func (m *Manager) Reset()

type Queue

type Queue interface {
	Resource

	Listen(target string) error
	Fetch(target string) ([][]byte, error)
	Publish(target string, payload []byte) error
}

type Resource

type Resource interface {
	Ready() error
	Reset() error
}

type Shell

type Shell interface {
	Resource

	Exec(command string, arguments ...string) error
	Stdout() (string, error)
	Stderr() (string, error)
}

Directories

Path Synopsis
database
http
queue
nsq

Jump to

Keyboard shortcuts

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