common_types

package
v0.0.0-...-b14d210 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2017 License: GPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VALID_MODULE_NAME_RE *regexp.Regexp = regexp.MustCompile(
	"^[A-Za-z][0-9A-Za-z_]*$",
)
View Source
var WRAPPING_MAGICK string = "DNETMAGICK"
View Source
var WRAPPING_MAGICK_B []byte = bytes.NewBufferString(WRAPPING_MAGICK).Bytes()

Functions

func IsApplicationNameCorrect

func IsApplicationNameCorrect(text string) bool

func IsValidModuleName

func IsValidModuleName(value string) bool

func ParseUDPBeaconMessage

func ParseUDPBeaconMessage(data []byte) (string, error)

func RenderUDPBeaconMessage

func RenderUDPBeaconMessage(value string) []byte

Types

type Address

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

func AddressNew

func AddressNew(value string) (*Address, error)

func (*Address) String

func (self *Address) String() string

type ApplicationCommunicator

type ApplicationCommunicator interface {
	GetDBConnection() *gorm.DB // Application's own db connection

	GetLogger() gologger.LoggerI

	Connect(

		to_who *Address,

		as_service string,

		to_service string,
	) (
		*net.Conn,
		error,
	)

	ServeConnection(
		who *Address,
		conn net.Conn,
	) error

	PossiblyNodeDiscovered(address NetworkAddress) error

	GetInnodeRPC(target_app_name string) (*rpc.Client, error)
}

This communicator is the standard way for application (module) to interact with DNet and other applications

type ApplicationControllerI

type ApplicationControllerI interface {
	GetBuiltinModules() ApplicationModuleMap
	GetImportedModules() ApplicationModuleMap
	GetModuleInstances() ApplicationModuleInstanceMap

	IsModuleExists(name *ModuleName) bool
	IsModuleBuiltin(name *ModuleName) bool
	GetModule(name *ModuleName) ApplicationModule

	IsInstanceExists(name *ModuleName) bool
	IsInstanceBuiltin(name *ModuleName) bool
	GetInstance(name *ModuleName) ApplicationModuleInstance

	GetInnodeRPC(
		who_asks *ModuleName,
		target_name *ModuleName,
	) (*rpc.Client, error)
}

type ApplicationModule

type ApplicationModule interface {
	Name() *ModuleName

	Title() string
	Description() string

	DependsOn() []string // module names which required to be enabled

	// If calling instance's Start() Stop() and Status() methods have sence
	IsWorker() bool

	IsNetwork() bool

	// If instance can be called to show it's window
	HaveUI() bool

	// DNet will not do automatic rekeys to not try to gues better time. Instead,
	// UI should provide user with flexible tools for user to decide on he's own
	// when he's need to do rekeys
	Instantiate(com ApplicationCommunicator) (ApplicationModuleInstance, error)
}

type ApplicationModuleInstance

type ApplicationModuleInstance interface {

	// Those may be called only if Module's IsWorker() returns true.
	// If Module's IsWorker() returns false, instance have simply
	// impliment them as noop.
	Start() chan bool
	Stop() chan bool
	Restart() chan bool
	Status() *workerstatus.WorkerStatus

	// This is for modules with isNetwork() == true. Controller calling this
	// than wants to connect to some particular node in this network.
	Connect(
		address NetworkAddress,
	) (*net.Conn, error)

	ServeConn(
		local bool,
		calling_app_name string,
		to_svc string,
		who *Address,
		conn net.Conn,
	) error

	// should return module's ui of some sort. If module has no window and it's
	// HaveUI() result's to false, then GetUI() should return non-nil error
	// stating so. anyway, DNet Implimenting Software should not allow user to
	// call GetUI() if HaveUI() results to false
	GetUI(interface{}) (interface{}, error)

	GetInnodeRPC(calling_app_name string) (*rpc.Client, error)
}

type ApplicationModuleInstanceMap

type ApplicationModuleInstanceMap map[string]ApplicationModuleInstance

type ApplicationModuleMap

type ApplicationModuleMap map[string]ApplicationModule

type IncommingRPCHandler

type IncommingRPCHandler struct{}

type ModuleChecksum

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

func ModuleChecksumNewFromString

func ModuleChecksumNewFromString(checksum string) (*ModuleChecksum, error)

func (*ModuleChecksum) Meth

func (self *ModuleChecksum) Meth() string

func (*ModuleChecksum) String

func (self *ModuleChecksum) String() string

func (*ModuleChecksum) Sum

func (self *ModuleChecksum) Sum() string

func (*ModuleChecksum) Valid

func (self *ModuleChecksum) Valid() bool

type ModuleName

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

func ModuleNameNew

func ModuleNameNew(value string) (*ModuleName, error)

func ModuleNameNewF

func ModuleNameNewF(value string) *ModuleName

func (*ModuleName) Value

func (self *ModuleName) Value() string

type NetworkAddress

type NetworkAddress string

func NetworkAddressNewFromString

func NetworkAddressNewFromString(value string) NetworkAddress

func (NetworkAddress) String

func (self NetworkAddress) String() string

Jump to

Keyboard shortcuts

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