router

package
v0.0.0-...-58575ba Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAdapterID

func GetAdapterID(MID string) (string, error)

GetAdapterID retrieves the AdapterID from a MID.

func GetAllActiveRoutes

func GetAllActiveRoutes() structs.NRoutes

GetAllActiveRoutes returns a list of Routes that have been returned by the Service Cache queries - hence all "active" routes.

func GetAllRoutes

func GetAllRoutes() structs.NRoutes

GetAllRoutes returns a list of all configured routes.

func GetAreaID

func GetAreaID(alias string) (string, error)

GetAreaID returns the AreaID for a Area (City) name, using the aliases in the config.json file.

func GetAreaRoutes

func GetAreaRoutes(areaID string) (structs.NRoutes, error)

GetAreaRoutes returns a list of Routes (structs.NRoutes) for the specified Area.

func GetChAreaAdp

func GetChAreaAdp() chan map[string][]string

GetChAreaAdp returns the channel used to update the areaAdapters index.

func GetChRouteUpd

func GetChRouteUpd() chan map[structs.NRoute]bool

GetChRouteUpd returns the channel used to update the Route Data indexed by AreaID (received from Services).

func GetMonitorAddress

func GetMonitorAddress() string

GetMonitorAddress returns the Monitor Address.

func GetNetworkConfig

func GetNetworkConfig() (address, protocol, certFile, keyFile string)

GetNetworkConfig returns the network configuration for the Engine.

func GetSearchRadius

func GetSearchRadius() (min, max int)

GetSearchRadius returns the Min and Max Search Radius values.

func Init

func Init(configFile string) error

Init loads the config files.

func RoutesAll

func RoutesAll() (routes structs.NRoutes, err error)

RoutesAll returns all routes from all CONFIG'ured adapters. This call does not use the Services cache for this list - it uses the config.json file.

func RoutesArea

func RoutesArea(areaID string) (routes structs.NRoutes, err error)

RoutesArea returns the route list for an AreaID (i.e. City).

func RoutesMID

func RoutesMID(mid structs.ServiceID) (routes structs.NRoutes, err error)

RoutesMID returns the route list for a ReportID.

func RoutesRID

func RoutesRID(rid structs.ReportID) (routes structs.NRoutes, err error)

RoutesRID returns the route list for a ReportID.

func ValidateRID

func ValidateRID(rid structs.ReportID) bool

ValidateRID verifies the ReportID is routable.

Types

type Adapter

type Adapter struct {
	ID      string     //
	Type    string     `json:"type"`
	Address string     `json:"address"`
	Startup AdpStartup `json:"startup"`
	// contains filtered or unexported fields
}

Adapter represents an active Adapter.

func GetAdapter

func GetAdapter(id string) (*Adapter, error)

GetAdapter retrieves a pointer to the Adapter from a ID.

func GetAreaAdapters

func GetAreaAdapters(areaID string) ([]*Adapter, error)

GetAreaAdapters returns a list of the Adapters that provide services to the specified Area.

func (*Adapter) AdpID

func (adp *Adapter) AdpID() string

AdpID returns the Adapter ID

func (*Adapter) Call

func (adp *Adapter) Call(serviceMethod string, args interface{}, reply interface{}) error

Call invokes the RPC Client.Call() function (see https://golang.org/pkg/net/rpc/#Client)

func (*Adapter) Connected

func (adp *Adapter) Connected() bool

Connected returns the current connection status of the adapter RPC connection.

func (Adapter) String

func (adp Adapter) String() string

String returns a formatted representation of Adapter.

type Adapters

type Adapters struct {
	AuxProgs auxiliaryProgs `json:"auxiliary"`
	Network  struct {
		Address  string `json:"address"`
		Protocol string `json:"protocol"`
		CertFile string `json:"certFile"`
		KeyFile  string `json:"keyFile"`
	} `json:"network"`
	Monitor struct {
		Address string `json:"address"`
	} `json:"monitor"`
	General struct {
		SearchRadiusMin int `json:"searchRadiusMin"`
		SearchRadiusMax int `json:"searchRadiusMax"`
	} `json:"general"`
	Adapters map[string]*Adapter `json:"adapters"` // Index: AdpID
	Areas    map[string]*Area    `json:"areas"`    // Index: AreaID

	sync.RWMutex
	// contains filtered or unexported fields
}

Adapters is the list of all active Adapters.

func (Adapters) String

func (r Adapters) String() string

String returns a formatted representation of Adapters.

type AdpRPCer

type AdpRPCer interface {
	AdpID() string
	Connected() bool
	Call(serviceMethod string, args interface{}, reply interface{}) error
}

AdpRPCer is an interface to the Adapter RPC status and Client.

func GetRouteAdapter

func GetRouteAdapter(route structs.NRoute) (AdpRPCer, error)

GetRouteAdapter gets a pointer to the Adapter for the specified route.

type AdpStartup

type AdpStartup struct {
	Autostart bool     `json:"autostart"`
	Dir       string   `json:"dir"`
	Cmd       string   `json:"cmd"`
	Args      []string `json:"args"`
}

AdpStartup represents the startup data for an adapter.

type Area

type Area struct {
	ID      string   //
	Name    string   `json:"name"`
	Aliases []string `json:"aliases"`
}

Area represents a Service Area.

func (Area) String

func (a Area) String() string

String returns a formatted representation of Adapter.

type RPCCallMgr

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

RPCCallMgr manages the RPC call(s) to service a request.

func NewRPCCallMgr

func NewRPCCallMgr(reqmgr requester) (*RPCCallMgr, error)

NewRPCCallMgr returns a RPCCallMgr instance, with routes as per the requester interface.

func (*RPCCallMgr) Run

func (r *RPCCallMgr) Run() error

Run executes all RPC calls.

func (RPCCallMgr) String

func (r RPCCallMgr) String() string

-------------------------------- String ---------------------------------

Jump to

Keyboard shortcuts

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