dataprovider

package
v0.0.0-...-2ebb9f0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterPlugin

func RegisterPlugin(plugin string, newFunc NewPlugin)

RegisterPlugin registers data adapter plugin.

Types

type AuthInfo

type AuthInfo struct {
	IsAuthorized bool
	Permissions  map[string]string
}

AuthInfo authorization info.

type BaseAdapter

type BaseAdapter struct {
	Name string
	Data map[string]*BaseData
	sync.Mutex
	SubscribeChannel chan map[string]interface{}
}

BaseAdapter base adapter.

func NewBaseAdapter

func NewBaseAdapter() (adapter *BaseAdapter, err error)

NewBaseAdapter creates base adapter.

func (*BaseAdapter) Close

func (adapter *BaseAdapter) Close()

Close closes adapter.

func (*BaseAdapter) GetData

func (adapter *BaseAdapter) GetData(pathList []string) (data map[string]interface{}, err error)

GetData returns data by path.

func (*BaseAdapter) GetName

func (adapter *BaseAdapter) GetName() (name string)

GetName returns adapter name.

func (*BaseAdapter) GetPathList

func (adapter *BaseAdapter) GetPathList() (pathList []string, err error)

GetPathList returns list of all pathes for this adapter.

func (*BaseAdapter) GetSubscribeChannel

func (adapter *BaseAdapter) GetSubscribeChannel() (channel <-chan map[string]interface{})

GetSubscribeChannel returns channel on which data changes will be sent.

func (*BaseAdapter) IsPathPublic

func (adapter *BaseAdapter) IsPathPublic(path string) (result bool, err error)

IsPathPublic returns true if requested data accessible without authorization.

func (*BaseAdapter) SetData

func (adapter *BaseAdapter) SetData(data map[string]interface{}) (err error)

SetData sets data by pathes.

func (*BaseAdapter) Subscribe

func (adapter *BaseAdapter) Subscribe(pathList []string) (err error)

Subscribe subscribes for data changes.

func (*BaseAdapter) Unsubscribe

func (adapter *BaseAdapter) Unsubscribe(pathList []string) (err error)

Unsubscribe unsubscribes from data changes.

func (*BaseAdapter) UnsubscribeAll

func (adapter *BaseAdapter) UnsubscribeAll() (err error)

UnsubscribeAll unsubscribes from all data changes.

type BaseData

type BaseData struct {
	Public   bool
	ReadOnly bool
	Value    interface{}
	// contains filtered or unexported fields
}

BaseData base data type.

type DataAdapter

type DataAdapter interface {
	// Close closes adapter
	Close()
	// GetName returns adapter name
	GetName() (name string)
	// GetPathList returns list of all pathes for this adapter
	GetPathList() (pathList []string, err error)
	// IsPathPublic returns true if requested data accessible without authorization
	IsPathPublic(path string) (result bool, err error)
	// GetData returns data by path
	GetData(pathList []string) (data map[string]interface{}, err error)
	// SetData sets data by pathes
	SetData(data map[string]interface{}) (err error)
	// GetSubscribeChannel returns channel on which data changes will be sent
	GetSubscribeChannel() (channel <-chan map[string]interface{})
	// Subscribe subscribes for data changes
	Subscribe(pathList []string) (err error)
	// Unsubscribe unsubscribes from data changes
	Unsubscribe(pathList []string) (err error)
	// UnsubscribeAll unsubscribes from all data changes
	UnsubscribeAll() (err error)
}

DataAdapter interface to data adapter.

type DataProvider

type DataProvider struct {
	sync.Mutex
	// contains filtered or unexported fields
}

DataProvider interface for geeting vehicle data.

func New

func New(config *config.Config) (provider *DataProvider, err error)

New returns pointer to DataProvider.

func (*DataProvider) Close

func (provider *DataProvider) Close()

Close closes data provider.

func (*DataProvider) GetData

func (provider *DataProvider) GetData(path string, authInfo *AuthInfo) (data interface{}, err error)

GetData returns VIS data.

func (*DataProvider) GetSubscribeIDs

func (provider *DataProvider) GetSubscribeIDs() (result []uint64)

GetSubscribeIDs returns list of active subscribe ID.

func (*DataProvider) SetData

func (provider *DataProvider) SetData(path string, data interface{}, authInfo *AuthInfo) (err error)

SetData sets VIS data.

func (*DataProvider) Subscribe

func (provider *DataProvider) Subscribe(
	path string, authInfo *AuthInfo,
) (id uint64, channel <-chan interface{}, err error)

Subscribe subscribes for data change.

func (*DataProvider) Unsubscribe

func (provider *DataProvider) Unsubscribe(id uint64, authInfo *AuthInfo) (err error)

Unsubscribe unsubscribes from data change.

type NewPlugin

type NewPlugin func(configJSON json.RawMessage) (adapter DataAdapter, err error)

NewPlugin plugin new function.

type PathFilter

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

PathFilter path filter structure.

func CreatePathFilter

func CreatePathFilter(path string) (filter *PathFilter, err error)

CreatePathFilter creates path filter.

func (*PathFilter) Match

func (filter *PathFilter) Match(path string) (result bool)

Match returns true is path matches the filter.

Jump to

Keyboard shortcuts

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