db

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InsertOrUpdateTimeoutSec is the timeout seconds of InsertOrUpdateHostFlows.
	InsertOrUpdateTimeoutSec = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*pgx.Conn
}

DB represents a Database handler.

func New

func New(dbURL string) (*DB, error)

New creates the DB object.

func (*DB) CreateSchema

func (db *DB) CreateSchema() error

CreateSchema creates the table schemas defined by the paths including Schemas.

func (*DB) FindActiveFlows

func (db *DB) FindActiveFlows(cond *FindFlowsCond) (Flows, error)

FindActiveFlows queries active flows to CMDB by the slice of ipaddrs.

func (*DB) FindPassiveFlows

func (db *DB) FindPassiveFlows(cond *FindFlowsCond) (Flows, error)

FindPassiveFlows queries passive flows to CMDB by the slice of ipaddrs.

func (*DB) InsertOrUpdateHostFlows

func (db *DB) InsertOrUpdateHostFlows(flows []*probe.HostFlow) error

InsertOrUpdateHostFlows insert host flows or update it if the same flow exists.

func (*DB) Shutdown added in v0.7.1

func (db *DB) Shutdown() error

Shutdown finishes the DB connection.

type FindFlowsCond added in v0.6.0

type FindFlowsCond struct {
	Addrs []net.IP
	Since time.Time
	Until time.Time
}

FindFlowsCond represents a query condition for FindActiveFlows or FindPassiveFlows.

type Flow

type Flow struct {
	ActiveNode  *Node
	PassiveNode *Node
	Connections int
}

Flow represents a flow between a active node and a passive node.

type Flows

type Flows map[string][]*Flow // flows group by

Flows represents a collection of flow.

type Node

type Node struct {
	IPAddr net.IP
	Port   int    // 0 if active node
	Pgid   int    // Process Group ID (Linux)
	Pname  string // Process Name (Linux)
}

Node represents a minimum unit of a graph tree.

func (*Node) String

func (n *Node) String() string

type TestDB added in v0.7.1

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

TestDB represents a database resource for testing.

func NewTestDB

func NewTestDB() *TestDB

NewTestDB creates database instance for testing.

func (*TestDB) GetURL added in v0.7.1

func (tdb *TestDB) GetURL() *url.URL

GetURL returnes the URL for database endpoint.

func (*TestDB) Purge added in v0.7.1

func (tdb *TestDB) Purge()

Purge purges the database

Jump to

Keyboard shortcuts

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