resourcemanager

package
v0.0.0-...-45c4399 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 11 Imported by: 0

README

ResourceManager

A Resource is a device that can communicate with this member server.

Typically this is an rfid reader, but it could potentially be other things on the network.

The Resource Manager will handle communication with these devices.

Documentation

Index

Constants

View Source
const (
	// StatusGood - the resource is online and up to date
	StatusGood = iota
	// StatusOutOfDate - the resource does not have the most up to date information
	StatusOutOfDate
	// StatusOffline - the resource is not reachable
	StatusOffline
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EventLogPayload

type EventLogPayload struct {
	Time     int    `json:"time"`
	Username string `json:"username"`
	RFID     string `json:"uid"`
	Door     string `json:"door"`
}

{"cmd":"log","type":"access","time":1631240207,"isKnown":"true","access":"Always","username":"Stanley Hash","uid":"f3ec6234","door":"frontdoor"}

type HeartBeat

type HeartBeat struct {
	ResourceName string `json:"door"`
}

type ResourceManager

type ResourceManager struct {
	datastore.DataStore
	// contains filtered or unexported fields
}

func New

func New(ms mqttServer, store datastore.DataStore, notifier notifier, logger logger) *ResourceManager

func (ResourceManager) CheckStatus

func (rm ResourceManager) CheckStatus(r models.Resource)

CheckStatus will publish an mqtt command that requests for a specific device to verify that

the resource has the correct and up to date access list
It will do this by hashing the list retrieved from the DB and comparing it
with the hash that the resource reports

func (ResourceManager) DeleteResourceACL

func (rm ResourceManager) DeleteResourceACL()

func (ResourceManager) EnableValidUIDs

func (rm ResourceManager) EnableValidUIDs()

func (*ResourceManager) HealthCheckHandler

func (rm *ResourceManager) HealthCheckHandler(client mqtt.Client, msg mqtt.Message)

HealthCheck -- this is the mqtt messageHandler that runs when a resource checks in

we expect the payload to be json that marshals to `ACLResponse` which includes the name
and a hash of it's ACL
if the ACL hash doesn't match what we have in the database, we will trigger an update to push
to the resource

func (ResourceManager) MQTT

func (rm ResourceManager) MQTT() mqtt.MQTTServer

func (*ResourceManager) OnAccessEventHandler

func (rm *ResourceManager) OnAccessEventHandler(payload models.LogMessage)

OnAccessEvent - post the event to slack. This could also get shoved in the DB eventually

func (*ResourceManager) OnHeartBeatHandler

func (rm *ResourceManager) OnHeartBeatHandler(client mqtt.Client, msg mqtt.Message)

OnHeartBeat handles heartbeats from

func (*ResourceManager) OnRemoveInvalidRequestHandler

func (rm *ResourceManager) OnRemoveInvalidRequestHandler(client mqtt.Client, msg mqtt.Message)

go through and remove members rfid fobs that are listed as invalid

func (ResourceManager) Open

func (rm ResourceManager) Open(resource models.Resource)

func (ResourceManager) PushOne

func (rm ResourceManager) PushOne(m models.Member)

PushOne - update one user on the resources

func (*ResourceManager) ReceiveHandler

func (rm *ResourceManager) ReceiveHandler(client mqtt.Client, msg mqtt.Message)

func (ResourceManager) RemoveMember

func (rm ResourceManager) RemoveMember(memberAccess models.MemberAccess)

func (ResourceManager) RemoveOne

func (rm ResourceManager) RemoveOne(member models.Member)

RemoveOne - remove a member from all resources

func (ResourceManager) RemovedInvalidUIDs

func (rm ResourceManager) RemovedInvalidUIDs()

func (ResourceManager) UpdateResourceACL

func (rm ResourceManager) UpdateResourceACL(r models.Resource) error

UpdateResourceACL pulls a resource's accesslist from the DB and pushes it to the resource

func (ResourceManager) UpdateResources

func (rm ResourceManager) UpdateResources()

UpdateResources - publish an MQTT message to add a member to the actual device

Jump to

Keyboard shortcuts

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