impl

package
v0.0.0-...-61237ac Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Carriers map[string]*Carrier

Carriers is configurations from config file

View Source
var Hubs map[string]*Office

Hubs caches carrier's hub offices

View Source
var Thresholds map[string]*Threshold

Thresholds specifies environment requirements for transporting specified products

Functions

func Initialize

func Initialize(configFile string) error

Initialize carrier's office, routes and containers

func InitializeGraph

func InitializeGraph(graph *GraphManager) error

InitializeGraph inserts carrier nodes and edges into TGDB

func IsMonitored

func IsMonitored(product string) bool

IsMonitored returns true if a threshold is defined for the specified product

func PickupPackage

func PickupPackage(packageID string) error

PickupPackage simulates pickup of a package of specified uid

func PrintShippingLabel

func PrintShippingLabel(request string) ([]byte, error)

PrintShippingLabel processes a PackageConfig JSON request

func QueryPackageTimeline

func QueryPackageTimeline(packageID string) ([]byte, error)

QueryPackageTimeline return transit timeline of a package of specified uid

Types

type Address

type Address struct {
	UID           string  `json:"-"`
	Street        string  `json:"street"`
	City          string  `json:"city"`
	StateProvince string  `json:"state-province"`
	PostalCd      string  `json:"postal-code"`
	Country       string  `json:"country"`
	Longitude     float64 `json:"longitude"`
	Latitude      float64 `json:"latitude"`
}

Address for sender and recipient

type AddressInfo

type AddressInfo struct {
	StateProvince string
	Longitude     float64
	Latitude      float64
}

AddressInfo contains key data for shipping

type Carrier

type Carrier struct {
	Name           string             `json:"name"`
	Description    string             `json:"description"`
	BlockchainUser string             `json:"blockchainUser"`
	Offices        map[string]*Office `json:"offices"`
}

Carrier defines a carrier and its office locations

type Container

type Container struct {
	UID      string
	ConsType string
	Embedded map[string]*Container
	Product  string
}

Container describes container or vehicle

type Content

type Content struct {
	UID            string `json:"-"`
	Product        string `json:"product"`
	Description    string `json:"description"`
	Producer       string `json:"producer"`
	ItemCount      int    `json:"count"`
	StartLotNumber string `json:"start-lot-number"`
	EndLotNumber   string `json:"end-lot-number"`
}

Content contained in a package

type DBConfig

type DBConfig struct {
	URL    string `json:"url"`
	User   string `json:"user"`
	Passwd string `json:"passwd"`
}

DBConfig configures connection of graph DB

var GraphDBConfig *DBConfig

GraphDBConfig specifies connection of graph DB for package tracking

type DemoConfig

type DemoConfig struct {
	Carriers map[string]*Carrier   `json:"carriers"`
	Products map[string]*Threshold `json:"products"`
	GraphDB  *DBConfig             `json:"graphdb"`
	Monitor  *MonitorConfig        `json:"monitoring"`
}

DemoConfig defines configuration data for the demo

type GraphManager

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

GraphManager encapsulates standard graph DB operations

func GetTGConnection

func GetTGConnection() (*GraphManager, error)

GetTGConnection returns a new connection of Graph DB

func (*GraphManager) Commit

func (g *GraphManager) Commit() (tgdb.TGResultSet, tgdb.TGError)

Commit commits the current transaction

func (*GraphManager) CreateEdge

func (g *GraphManager) CreateEdge(typeName string, from, to tgdb.TGNode) (tgdb.TGEdge, tgdb.TGError)

CreateEdge creates an empty edge in default graph

func (*GraphManager) CreateNode

func (g *GraphManager) CreateNode(typeName string) (tgdb.TGNode, tgdb.TGError)

CreateNode creates an empty node in default graph

func (*GraphManager) Disconnect

func (g *GraphManager) Disconnect() tgdb.TGError

Disconnect disconnects from TGDB server

func (*GraphManager) GetNodeByKey

func (g *GraphManager) GetNodeByKey(nodeType string, keyValues map[string]interface{}) (tgdb.TGNode, tgdb.TGError)

GetNodeByKey returns a node of specified type and primary key-values

func (*GraphManager) InsertEntity

func (g *GraphManager) InsertEntity(entity tgdb.TGEntity) tgdb.TGError

InsertEntity inserts a node or edge into graph

func (*GraphManager) Query

func (g *GraphManager) Query(grem string) ([]interface{}, error)

Query executes a Gremlin query

func (*GraphManager) UpdateEntity

func (g *GraphManager) UpdateEntity(entity tgdb.TGEntity) tgdb.TGError

UpdateEntity marks a node or edge for update

type Measurement

type Measurement struct {
	PeriodStart time.Time
	PeriodEnd   time.Time
	MinValue    float64
	MaxValue    float64
	InViolation bool
}

Measurement is randomly generated measurement against a threshold

type MonitorConfig

type MonitorConfig struct {
	Enabled           bool    `json:"enabled"`
	ViolationRate     float64 `json:"violationRate"`
	BlockchainUser    string  `json:"blockchainUser"`
	BlockchainService string  `json:"blockchainService"`
	Pickup            string  `json:"pickup"`
	Transfer          string  `json:"transfer"`
	TransferAck       string  `json:"transferAck"`
	Delivery          string  `json:"deliver"`
	UpdateTemperature string  `json:"updateTemperature"`
}

MonitorConfig contians configuration of blockchain service user and request types

var FabricConfig *MonitorConfig

FabricConfig specifies configuration of Hyperledger Fabric service requests

type Office

type Office struct {
	Iata        string  `json:"iata"`
	IsHub       bool    `json:"hub"`
	Carrier     string  `json:"carrier"`
	Description string  `json:"description"`
	GMTOffset   string  `json:"gmtOffset"`
	Longitude   float64 `json:"longitude"`
	Latitude    float64 `json:"latitude"`
	State       string  `json:"state"`
	Routes      map[string]*Route
}

Office defines an office location of a carrier

type Package

type Package struct {
	UID             string   `json:"uid"`
	QRCode          []byte   `json:"-"`
	HandlingCd      string   `json:"handling"`
	Product         string   `json:"-"`
	Height          float64  `json:"-"`
	Width           float64  `json:"-"`
	Depth           float64  `json:"-"`
	Weight          float64  `json:"-"`
	DryIceWeight    float64  `json:"-"`
	Carrier         string   `json:"carrier"`
	CreatedTime     string   `json:"created"`
	EstPickupTime   string   `json:"-"`
	EstDeliveryTime string   `json:"-"`
	Sender          string   `json:"sender"`
	From            *Address `json:"from"`
	Recipient       string   `json:"recipient"`
	To              *Address `json:"to"`
}

Package describes attributes of a package; json attributes will be stored in QR code

type PackageInfo

type PackageInfo struct {
	UID           string
	HandlingCd    string
	Product       string
	Carrier       string
	EstPickupTime time.Time
	From          *AddressInfo
	To            *AddressInfo
}

PackageInfo contains key data for shipping

type PackageRequest

type PackageRequest struct {
	UID          string   `json:"uid,omitempty"`
	HandlingCd   string   `json:"handling"`
	Height       float64  `json:"height"`
	Width        float64  `json:"width"`
	Depth        float64  `json:"depth"`
	Weight       float64  `json:"weight"`
	DryIceWeight float64  `json:"dry-ice-weight,omitempty"`
	Sender       string   `json:"sender"`
	From         *Address `json:"from"`
	Recipient    string   `json:"recipient"`
	To           *Address `json:"to"`
	Content      *Content `json:"content"`
}

PackageRequest defines JSON string for a shipment request

type PackageResponse

type PackageResponse struct {
	UID             string   `json:"uid"`
	HandlingCd      string   `json:"handling"`
	Product         string   `json:"product"`
	Carrier         string   `json:"carrier"`
	CreatedTime     string   `json:"created"`
	EstPickupTime   string   `json:"estimated-pickup"`
	EstDeliveryTime string   `json:"estimated-delivery"`
	Sender          string   `json:"sender"`
	From            *Address `json:"from"`
	Recipient       string   `json:"recipient"`
	To              *Address `json:"to"`
}

PackageResponse returns data of newly created shipping label

type PackageTransaction

type PackageTransaction struct {
	UID           string  `json:"uid"`
	EventTime     string  `json:"eventTime"`
	Latitude      float64 `json:"latitude"`
	Longitude     float64 `json:"longitude"`
	Carrier       string  `json:"carrier,omitempty"`
	ToCarrier     string  `json:"toCarrier,omitempty"`
	PackageDetail string  `json:"packageDetail,omitempty"`
}

PackageTransaction contains data sent to blockchain for key package transactions where PackageDetail is json serialized from PackageRequest

type Route

type Route struct {
	RouteNbr        string
	RouteType       string
	SchdDepartTime  string
	SchdArrivalTime string
	From            *Office
	To              *Office
	Vehicle         *Container
}

Route generated for carriers

type TemperatureUpdate

type TemperatureUpdate struct {
	UID         string  `json:"uid"`
	ContainerID string  `json:"containerID"`
	PeriodStart string  `json:"periodStart"`
	EventTime   string  `json:"eventTime"`
	MinValue    float64 `json:"minValue"`
	MaxValue    float64 `json:"maxValue"`
	InViolation bool    `json:"inViolation"`
}

TemperatureUpdate contains data sent to blockchain to update package temperature

type Threshold

type Threshold struct {
	Name     string  `json:"name"`
	ItemType string  `json:"handlingCd"`
	MinValue float64 `json:"minValue"`
	MaxValue float64 `json:"maxValue"`
	UOM      string  `json:"uom"`
}

Threshold specifies requirements for transporting hazmat

Jump to

Keyboard shortcuts

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