README ¶
Redis Implementation Notes
Core Data
Events and Readings
pkg/models/event
is stored as a marshalled value using the event id as the key.
Sorted sets are used to track events sorted by most recently added, created timestamp (both relative to all events and scoped to the source device), and the pushed timestamp. Readings are stored similarly in their own sorted sets.
Given
var e Event
and
var e models.Event = models.Event{
ID: "57ba04a1189b95b8afcdafd7",
Pushed: 1471806399999,
Device: "123456789",
Created: 1464039917100,
Modified: 1474774741088,
Origin: 1471806386919,
Event: "",
Reading: []Reading{
Reading {
ID: "57b9fe08189b95b8afcdafd4",
Pushed: 0,
Created: 1471806984866,
Modified: 1471807130870,
Origin: 1471806386919,
Name: "temperature",
Value: "39"
},
Reading {
ID: "57e745efe4b0ca8e6d7116d7",
Pushed: 0,
Created: 1474774511737,
Modified: 1474774511737,
Origin: 1471806386919,
Name: "power",
Value: "38"
},
...
}
}
then
Sorted Set Key | Score | Member |
---|---|---|
event | 0 | 57ba04a1189b95b8afcdafd7 |
event:created | 1464039917100 | 57ba04a1189b95b8afcdafd7 |
event:pushed | 1471806399999 | 57ba04a1189b95b8afcdafd7 |
event:device:123456789 | 1464039917100 | 57ba04a1189b95b8afcdafd7 |
reading | 0 | 57b9fe08189b95b8afcdafd4 |
reading:created | 1471806984866 | 57b9fe08189b95b8afcdafd4 |
reading:device:123456789 | 1471806984866 | 57b9fe08189b95b8afcdafd4 |
reading:name:temperature | 1471806984866 | 57b9fe08189b95b8afcdafd4 |
reading | 0 | 57e745efe4b0ca8e6d7116d7 |
reading:created | 1474774511737 | 57e745efe4b0ca8e6d7116d7 |
reading:device:123456789 | 1474774511737 | 57e745efe4b0ca8e6d7116d7 |
reading:name:power | 1474774511737 | 57e745efe4b0ca8e6d7116d7 |
Notification Service
Each of Notification, Subscription, and Transmission objects are stored as a key/value pair where the key is the id of the object. The value is JSON marshalled string.
Given the migration away from BSON ids and toward UUID, all generated ids are UUIDs.
Changes:
- Add test at internal/pkg/db/test/db_notifications.go
- Create a separate folder at internal/pkg/db/redis_notification for migrating to master branch
- Implement db interface function according to internal/support/notifications/interfaces/db.go
Notifications
Notifications are queried by Slug, sender, time, labels, and status. To support those queries a sorted set with the index (e.g. slug) as the score and the value as the key of the notification object in question.
Data Type | Key | Value | Score |
---|---|---|---|
Sets | Entity ID | Entity | |
Sorted sets | "notification" | Entity ID | 0 |
Hashes | "notification:slug" | SlugName and Entity ID | |
Sorted sets | "notification:sender:{sender}" | Entity ID | 0 |
Sorted sets | "notification:status:{status}" | Entity ID | 0 |
Sorted sets | "notification:severity:{severity}" | Entity ID | 0 |
Sorted sets | "notification:created" | Entity ID | Timestamp |
Sorted sets | "notification:modified" | Entity ID | Timestamp |
Where LABEL and STATUS are a specific label or status, respectively.
Subscriptions
Subscriptions are queried by Slug, categories, labels, and receiver.
Data Type | Key | Value | Score |
---|---|---|---|
Sets | Entity ID | Entity | |
Sorted sets | "subscription" | Entity ID | 0 |
Hashes | "subscription:slug" | SlugName and Entity ID | |
Sorted sets | "subscription:receiver:{receiver}" | Entity ID | 0 |
Sets | "subscription🏷{label}" | Entity ID | |
Sets | "subscription:category:{category}" | Entity ID |
Given the migration of EdgeX to UUID from BSON Id, UUID is used for the id in the Redis implementation of the Notification service.
Transmission
Data Type | Key | Value | Score |
---|---|---|---|
Sets | Entity ID | Entity | |
Sorted sets | "transmission" | Entity ID | 0 |
Sorted sets | "transmission:slug:{slug}" | Entity ID | Timestamp |
Sorted sets | "transmission:status:{status}" | Entity ID | ResendCount |
Sorted sets | "transmission:resendcount:{resendcount}" | Entity ID | ResendCount |
Sorted sets | "transmission:created" | Entity ID | Timestamp |
Sorted sets | "transmission:modified" | Entity ID | Timestamp |
Documentation ¶
Overview ¶
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright (C) 2018 IOTech Ltd *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
******************************************************************************
- Copyright 2018 Redis Labs Inc. *
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License. ******************************************************************************
Index ¶
- Constants
- type Client
- func (c *Client) AddAddressable(a contract.Addressable) (string, error)
- func (c *Client) AddDevice(d contract.Device, commands []contract.Command) (string, error)
- func (c *Client) AddDeviceProfile(dp contract.DeviceProfile) (string, error)
- func (c *Client) AddDeviceReport(d contract.DeviceReport) (string, error)
- func (c *Client) AddDeviceService(ds contract.DeviceService) (string, error)
- func (c *Client) AddEvent(e correlation.Event) (id string, err error)
- func (c *Client) AddInterval(from contract.Interval) (id string, err error)
- func (c *Client) AddIntervalAction(from contract.IntervalAction) (id string, err error)
- func (c Client) AddNotification(n contract.Notification) (string, error)
- func (c *Client) AddProvisionWatcher(pw contract.ProvisionWatcher) (string, error)
- func (c *Client) AddReading(r contract.Reading) (id string, err error)
- func (c Client) AddSubscription(s contract.Subscription) (string, error)
- func (c Client) AddTransmission(t contract.Transmission) (string, error)
- func (c *Client) AddValueDescriptor(v contract.ValueDescriptor) (id string, err error)
- func (c Client) Cleanup() error
- func (c Client) CleanupOld(age int) error
- func (c *Client) CloseSession()
- func (c *Client) Connect() error
- func (c *Client) DeleteAddressableById(id string) error
- func (c *Client) DeleteDeviceById(id string) error
- func (c *Client) DeleteDeviceProfileById(id string) error
- func (c *Client) DeleteDeviceReportById(id string) error
- func (c *Client) DeleteDeviceServiceById(id string) error
- func (c *Client) DeleteEventById(id string) error
- func (c *Client) DeleteEventsByDevice(deviceId string) (int, error)
- func (c *Client) DeleteIntervalActionById(id string) (err error)
- func (c *Client) DeleteIntervalById(id string) (err error)
- func (c Client) DeleteNotificationById(id string) error
- func (c Client) DeleteNotificationBySlug(slug string) error
- func (c Client) DeleteNotificationsOld(age int) error
- func (c *Client) DeleteProvisionWatcherById(id string) error
- func (c *Client) DeleteReadingById(id string) error
- func (c *Client) DeleteReadingsByDevice(device string) error
- func (c *Client) DeleteSubscriptionById(id string) error
- func (c Client) DeleteSubscriptionBySlug(slug string) error
- func (c Client) DeleteTransmission(age int64, status contract.TransmissionStatus) error
- func (c *Client) DeleteValueDescriptorById(id string) error
- func (c *Client) EventById(id string) (event contract.Event, err error)
- func (c *Client) EventCount() (count int, err error)
- func (c *Client) EventCountByDeviceId(id string) (count int, err error)
- func (c *Client) Events() (events []contract.Event, err error)
- func (c *Client) EventsByChecksum(checksum string) (events []contract.Event, err error)
- func (c *Client) EventsByCreationTime(startTime, endTime int64, limit int) (events []contract.Event, err error)
- func (c *Client) EventsForDevice(id string) (events []contract.Event, err error)
- func (c *Client) EventsForDeviceLimit(id string, limit int) (events []contract.Event, err error)
- func (c *Client) EventsOlderThanAge(age int64) ([]contract.Event, error)
- func (c *Client) EventsPushed() (events []contract.Event, err error)
- func (c *Client) EventsWithLimit(limit int) (events []contract.Event, err error)
- func (c *Client) GetAddressableById(id string) (contract.Addressable, error)
- func (c *Client) GetAddressableByName(n string) (contract.Addressable, error)
- func (c *Client) GetAddressables() ([]contract.Addressable, error)
- func (c *Client) GetAddressablesByAddress(add string) ([]contract.Addressable, error)
- func (c *Client) GetAddressablesByPort(p int) ([]contract.Addressable, error)
- func (c *Client) GetAddressablesByPublisher(p string) ([]contract.Addressable, error)
- func (c *Client) GetAddressablesByTopic(t string) ([]contract.Addressable, error)
- func (c *Client) GetAllCommands() ([]contract.Command, error)
- func (c *Client) GetAllDeviceProfiles() ([]contract.DeviceProfile, error)
- func (c *Client) GetAllDeviceReports() ([]contract.DeviceReport, error)
- func (c *Client) GetAllDeviceServices() ([]contract.DeviceService, error)
- func (c *Client) GetAllDevices() ([]contract.Device, error)
- func (c *Client) GetAllProvisionWatchers() ([]contract.ProvisionWatcher, error)
- func (c *Client) GetCommandById(id string) (contract.Command, error)
- func (c *Client) GetCommandByNameAndDeviceId(cname string, did string) (contract.Command, error)
- func (c *Client) GetCommandsByDeviceId(did string) ([]contract.Command, error)
- func (c *Client) GetCommandsByName(n string) ([]contract.Command, error)
- func (c *Client) GetDeviceById(id string) (contract.Device, error)
- func (c *Client) GetDeviceByName(n string) (contract.Device, error)
- func (c *Client) GetDeviceProfileById(id string) (contract.DeviceProfile, error)
- func (c *Client) GetDeviceProfileByName(n string) (contract.DeviceProfile, error)
- func (c *Client) GetDeviceProfilesByManufacturer(man string) ([]contract.DeviceProfile, error)
- func (c *Client) GetDeviceProfilesByManufacturerModel(man string, mod string) ([]contract.DeviceProfile, error)
- func (c *Client) GetDeviceProfilesByModel(model string) ([]contract.DeviceProfile, error)
- func (c *Client) GetDeviceProfilesWithLabel(l string) ([]contract.DeviceProfile, error)
- func (c *Client) GetDeviceReportByDeviceName(n string) ([]contract.DeviceReport, error)
- func (c *Client) GetDeviceReportById(id string) (contract.DeviceReport, error)
- func (c *Client) GetDeviceReportByName(n string) (contract.DeviceReport, error)
- func (c *Client) GetDeviceReportsByAction(n string) ([]contract.DeviceReport, error)
- func (c *Client) GetDeviceReportsByScheduleEventName(n string) ([]contract.DeviceReport, error)
- func (c *Client) GetDeviceServiceById(id string) (contract.DeviceService, error)
- func (c *Client) GetDeviceServiceByName(n string) (contract.DeviceService, error)
- func (c *Client) GetDeviceServicesByAddressableId(id string) ([]contract.DeviceService, error)
- func (c *Client) GetDeviceServicesWithLabel(l string) ([]contract.DeviceService, error)
- func (c *Client) GetDevicesByProfileId(id string) ([]contract.Device, error)
- func (c *Client) GetDevicesByServiceId(id string) ([]contract.Device, error)
- func (c *Client) GetDevicesWithLabel(l string) ([]contract.Device, error)
- func (c Client) GetNewNormalNotifications(limit int) ([]contract.Notification, error)
- func (c Client) GetNewNotifications(limit int) ([]contract.Notification, error)
- func (c Client) GetNotificationById(id string) (notification contract.Notification, err error)
- func (c Client) GetNotificationBySender(sender string, limit int) ([]contract.Notification, error)
- func (c Client) GetNotificationBySlug(slug string) (notification contract.Notification, err error)
- func (c Client) GetNotifications() (n []contract.Notification, err error)
- func (c Client) GetNotificationsByEnd(end int64, limit int) ([]contract.Notification, error)
- func (c Client) GetNotificationsByLabels(labels []string, limit int) (notifications []contract.Notification, err error)
- func (c Client) GetNotificationsByStart(start int64, limit int) ([]contract.Notification, error)
- func (c Client) GetNotificationsByStartEnd(start int64, end int64, limit int) ([]contract.Notification, error)
- func (c *Client) GetProvisionWatcherById(id string) (contract.ProvisionWatcher, error)
- func (c *Client) GetProvisionWatcherByName(n string) (contract.ProvisionWatcher, error)
- func (c *Client) GetProvisionWatchersByIdentifier(k string, v string) (pw []contract.ProvisionWatcher, err error)
- func (c *Client) GetProvisionWatchersByProfileId(id string) ([]contract.ProvisionWatcher, error)
- func (c *Client) GetProvisionWatchersByServiceId(id string) ([]contract.ProvisionWatcher, error)
- func (c Client) GetSubscriptionByCategories(categories []string) (s []contract.Subscription, err error)
- func (c Client) GetSubscriptionByCategoriesLabels(categories []string, labels []string) (s []contract.Subscription, err error)
- func (c Client) GetSubscriptionById(id string) (s contract.Subscription, err error)
- func (c Client) GetSubscriptionByLabels(labels []string) (s []contract.Subscription, err error)
- func (c Client) GetSubscriptionByReceiver(receiver string) ([]contract.Subscription, error)
- func (c Client) GetSubscriptionBySlug(slug string) (s contract.Subscription, err error)
- func (c Client) GetSubscriptions() ([]contract.Subscription, error)
- func (c Client) GetTransmissionById(id string) (transmission contract.Transmission, err error)
- func (c Client) GetTransmissionsByEnd(end int64, limit int) (transmissions []contract.Transmission, err error)
- func (c Client) GetTransmissionsByNotificationSlug(slug string, limit int) (transmissions []contract.Transmission, err error)
- func (c Client) GetTransmissionsByNotificationSlugAndStartEnd(slug string, start int64, end int64, limit int) (transmissions []contract.Transmission, err error)
- func (c Client) GetTransmissionsByStart(start int64, limit int) (transmissions []contract.Transmission, err error)
- func (c Client) GetTransmissionsByStartEnd(start int64, end int64, limit int) (transmissions []contract.Transmission, err error)
- func (c Client) GetTransmissionsByStatus(limit int, status contract.TransmissionStatus) (transmissions []contract.Transmission, err error)
- func (c *Client) IntervalActionById(id string) (action contract.IntervalAction, err error)
- func (c *Client) IntervalActionByName(name string) (action contract.IntervalAction, err error)
- func (c *Client) IntervalActions() (actions []contract.IntervalAction, err error)
- func (c *Client) IntervalActionsByIntervalName(name string) (actions []contract.IntervalAction, err error)
- func (c *Client) IntervalActionsByTarget(name string) (actions []contract.IntervalAction, err error)
- func (c *Client) IntervalActionsWithLimit(limit int) (actions []contract.IntervalAction, err error)
- func (c *Client) IntervalById(id string) (interval contract.Interval, err error)
- func (c *Client) IntervalByName(name string) (interval contract.Interval, err error)
- func (c *Client) Intervals() (intervals []contract.Interval, err error)
- func (c *Client) IntervalsWithLimit(limit int) (intervals []contract.Interval, err error)
- func (c Client) MarkNotificationProcessed(n contract.Notification) error
- func (c *Client) ReadingById(id string) (reading contract.Reading, err error)
- func (c *Client) ReadingCount() (int, error)
- func (c *Client) Readings() (readings []contract.Reading, err error)
- func (c *Client) ReadingsByCreationTime(start, end int64, limit int) (readings []contract.Reading, err error)
- func (c *Client) ReadingsByDevice(id string, limit int) (readings []contract.Reading, err error)
- func (c *Client) ReadingsByDeviceAndValueDescriptor(deviceId, valueDescriptor string, limit int) (readings []contract.Reading, err error)
- func (c *Client) ReadingsByValueDescriptor(name string, limit int) (readings []contract.Reading, err error)
- func (c *Client) ReadingsByValueDescriptorNames(names []string, limit int) (readings []contract.Reading, err error)
- func (c *Client) ScrubAllEvents() (err error)
- func (c *Client) ScrubAllIntervalActions() (count int, err error)
- func (c *Client) ScrubAllIntervals() (count int, err error)
- func (c *Client) ScrubAllValueDescriptors() error
- func (c *Client) ScrubMetadata() (err error)
- func (c *Client) UpdateAddressable(a contract.Addressable) error
- func (c *Client) UpdateDevice(d contract.Device) error
- func (c *Client) UpdateDeviceProfile(dp contract.DeviceProfile) error
- func (c *Client) UpdateDeviceReport(dr contract.DeviceReport) error
- func (c *Client) UpdateDeviceService(ds contract.DeviceService) error
- func (c *Client) UpdateEvent(e correlation.Event) (err error)
- func (c *Client) UpdateInterval(from contract.Interval) (err error)
- func (c *Client) UpdateIntervalAction(from contract.IntervalAction) (err error)
- func (c Client) UpdateNotification(n contract.Notification) error
- func (c *Client) UpdateProvisionWatcher(pw contract.ProvisionWatcher) error
- func (c *Client) UpdateReading(r contract.Reading) error
- func (c Client) UpdateSubscription(s contract.Subscription) error
- func (c Client) UpdateTransmission(t contract.Transmission) error
- func (c *Client) UpdateValueDescriptor(v contract.ValueDescriptor) error
- func (c *Client) ValueDescriptorById(id string) (value contract.ValueDescriptor, err error)
- func (c *Client) ValueDescriptorByName(name string) (value contract.ValueDescriptor, err error)
- func (c *Client) ValueDescriptors() (values []contract.ValueDescriptor, err error)
- func (c *Client) ValueDescriptorsByLabel(label string) (values []contract.ValueDescriptor, err error)
- func (c *Client) ValueDescriptorsByName(names []string) (values []contract.ValueDescriptor, err error)
- func (c *Client) ValueDescriptorsByType(t string) (values []contract.ValueDescriptor, err error)
- func (c *Client) ValueDescriptorsByUomLabel(uomLabel string) (values []contract.ValueDescriptor, err error)
- type CoreDataClient
Constants ¶
const ( DeletedEventsCollection = "gc:" + db.EventsCollection DeletedReadingsCollection = "gc:" + db.ReadingsCollection )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Pool *redis.Pool // A thread-safe pool of connections to Redis BatchSize int // contains filtered or unexported fields }
Client represents a Redis client
func NewClient ¶
func NewClient(config db.Configuration, lc logger.LoggingClient) (*Client, error)
Return a pointer to the Redis client
func (*Client) AddAddressable ¶
func (c *Client) AddAddressable(a contract.Addressable) (string, error)
func (*Client) AddDevice ¶
/* ----------------------------- Device ---------------------------------- */
func (*Client) AddDeviceProfile ¶
func (c *Client) AddDeviceProfile(dp contract.DeviceProfile) (string, error)
func (*Client) AddDeviceReport ¶
func (c *Client) AddDeviceReport(d contract.DeviceReport) (string, error)
func (*Client) AddDeviceService ¶
func (c *Client) AddDeviceService(ds contract.DeviceService) (string, error)
func (*Client) AddEvent ¶
func (c *Client) AddEvent(e correlation.Event) (id string, err error)
Add a new event UnexpectedError - failed to add to database NoValueDescriptor - no existing value descriptor for a reading in the event
func (*Client) AddInterval ¶
Add a new schedule interval
func (*Client) AddIntervalAction ¶
func (c *Client) AddIntervalAction(from contract.IntervalAction) (id string, err error)
Add schedule interval action
func (Client) AddNotification ¶
func (c Client) AddNotification(n contract.Notification) (string, error)
******************************* NOTIFICATIONS **********************************
func (*Client) AddProvisionWatcher ¶
func (c *Client) AddProvisionWatcher(pw contract.ProvisionWatcher) (string, error)
func (*Client) AddReading ¶
Post a new reading Check if valuedescriptor exists in the database
func (Client) AddSubscription ¶
func (c Client) AddSubscription(s contract.Subscription) (string, error)
******************************* SUBSCRIPTIONS **********************************
func (Client) AddTransmission ¶
func (c Client) AddTransmission(t contract.Transmission) (string, error)
******************************* TRANSMISSIONS **********************************
func (*Client) AddValueDescriptor ¶
func (c *Client) AddValueDescriptor(v contract.ValueDescriptor) (id string, err error)
************************** VALUE DESCRIPTOR FUNCTIONS *************************** Add a value descriptor 409 - Formatting is bad or it is not unique 503 - Unexpected TODO: Check for valid printf formatting
func (Client) CleanupOld ¶
Cleanup delete old notifications and associated transmissions
func (*Client) CloseSession ¶
func (c *Client) CloseSession()
CloseSession closes the connections to Redis
func (*Client) DeleteAddressableById ¶
func (*Client) DeleteDeviceById ¶
func (*Client) DeleteDeviceProfileById ¶
func (*Client) DeleteDeviceReportById ¶
func (*Client) DeleteDeviceServiceById ¶
func (*Client) DeleteEventById ¶
Delete an event by ID. Readings are not deleted as this should be handled by the contract layer 404 - Event not found 503 - Unexpected problems
func (*Client) DeleteEventsByDevice ¶
DeleteEventsByDevice Delete events and readings associated with the specified deviceID
func (*Client) DeleteIntervalActionById ¶
Remove schedule interval action by id
func (*Client) DeleteIntervalById ¶
Remove schedule interval by ID
func (Client) DeleteNotificationById ¶
func (Client) DeleteNotificationBySlug ¶
func (Client) DeleteNotificationsOld ¶
DeleteNotificationsOld remove all the notifications that are older than the given age
func (*Client) DeleteProvisionWatcherById ¶
func (*Client) DeleteReadingById ¶
Delete a reading by ID 404 - can't find the reading with the given id
func (*Client) DeleteReadingsByDevice ¶
DeleteReadingsByDevice deletes readings associated with the specified device
func (*Client) DeleteSubscriptionById ¶
func (Client) DeleteSubscriptionBySlug ¶
func (Client) DeleteTransmission ¶
func (c Client) DeleteTransmission(age int64, status contract.TransmissionStatus) error
DeleteTransmission delete old transmission with specified status
func (*Client) DeleteValueDescriptorById ¶
Delete a value descriptor based on the ID
func (*Client) EventCount ¶
Get the number of events in Core Data
func (*Client) EventCountByDeviceId ¶
Get the number of events in Core Data for the device specified by id
func (*Client) Events ¶
********************** EVENT FUNCTIONS ******************************* Return all the events Sort the events in descending order by ID UnexpectedError - failed to retrieve events from the database
func (*Client) EventsByChecksum ¶
EventsByChecksum Get an event by checksum
func (*Client) EventsByCreationTime ¶
func (c *Client) EventsByCreationTime(startTime, endTime int64, limit int) (events []contract.Event, err error)
Return a list of events whos creation time is between startTime and endTime Limit the number of results by limit
func (*Client) EventsForDevice ¶
Get a list of events based on the device id
func (*Client) EventsForDeviceLimit ¶
Get a list of events based on the device id and limit
func (*Client) EventsOlderThanAge ¶
Get events that are older than a age
func (*Client) EventsPushed ¶
Get events that have been pushed (pushed field is not 0)
func (*Client) EventsWithLimit ¶
Return events up to the number specified UnexpectedError - failed to retrieve events from the database
func (*Client) GetAddressableById ¶
func (c *Client) GetAddressableById(id string) (contract.Addressable, error)
func (*Client) GetAddressableByName ¶
func (c *Client) GetAddressableByName(n string) (contract.Addressable, error)
func (*Client) GetAddressables ¶
func (c *Client) GetAddressables() ([]contract.Addressable, error)
func (*Client) GetAddressablesByAddress ¶
func (c *Client) GetAddressablesByAddress(add string) ([]contract.Addressable, error)
func (*Client) GetAddressablesByPort ¶
func (c *Client) GetAddressablesByPort(p int) ([]contract.Addressable, error)
func (*Client) GetAddressablesByPublisher ¶
func (c *Client) GetAddressablesByPublisher(p string) ([]contract.Addressable, error)
func (*Client) GetAddressablesByTopic ¶
func (c *Client) GetAddressablesByTopic(t string) ([]contract.Addressable, error)
func (*Client) GetAllCommands ¶
------------------------Command -------------------------------------*/
func (*Client) GetAllDeviceProfiles ¶
func (c *Client) GetAllDeviceProfiles() ([]contract.DeviceProfile, error)
func (*Client) GetAllDeviceReports ¶
func (c *Client) GetAllDeviceReports() ([]contract.DeviceReport, error)
/* ----------------------Device Report --------------------------*/
func (*Client) GetAllDeviceServices ¶
func (c *Client) GetAllDeviceServices() ([]contract.DeviceService, error)
func (*Client) GetAllProvisionWatchers ¶
func (c *Client) GetAllProvisionWatchers() ([]contract.ProvisionWatcher, error)
----------------------Provision Watcher -----------------------------*/
func (*Client) GetCommandById ¶
func (*Client) GetCommandByNameAndDeviceId ¶
func (*Client) GetCommandsByDeviceId ¶
func (*Client) GetCommandsByName ¶
func (*Client) GetDeviceByName ¶
func (*Client) GetDeviceProfileById ¶
func (c *Client) GetDeviceProfileById(id string) (contract.DeviceProfile, error)
/* -----------------------------Device Profile -----------------------------*/
func (*Client) GetDeviceProfileByName ¶
func (c *Client) GetDeviceProfileByName(n string) (contract.DeviceProfile, error)
func (*Client) GetDeviceProfilesByManufacturer ¶
func (c *Client) GetDeviceProfilesByManufacturer(man string) ([]contract.DeviceProfile, error)
func (*Client) GetDeviceProfilesByManufacturerModel ¶
func (*Client) GetDeviceProfilesByModel ¶
func (c *Client) GetDeviceProfilesByModel(model string) ([]contract.DeviceProfile, error)
func (*Client) GetDeviceProfilesWithLabel ¶
func (c *Client) GetDeviceProfilesWithLabel(l string) ([]contract.DeviceProfile, error)
func (*Client) GetDeviceReportByDeviceName ¶
func (c *Client) GetDeviceReportByDeviceName(n string) ([]contract.DeviceReport, error)
func (*Client) GetDeviceReportById ¶
func (c *Client) GetDeviceReportById(id string) (contract.DeviceReport, error)
func (*Client) GetDeviceReportByName ¶
func (c *Client) GetDeviceReportByName(n string) (contract.DeviceReport, error)
func (*Client) GetDeviceReportsByAction ¶
func (c *Client) GetDeviceReportsByAction(n string) ([]contract.DeviceReport, error)
func (*Client) GetDeviceReportsByScheduleEventName ¶
func (c *Client) GetDeviceReportsByScheduleEventName(n string) ([]contract.DeviceReport, error)
func (*Client) GetDeviceServiceById ¶
func (c *Client) GetDeviceServiceById(id string) (contract.DeviceService, error)
func (*Client) GetDeviceServiceByName ¶
func (c *Client) GetDeviceServiceByName(n string) (contract.DeviceService, error)
/* ----------------------------- Device Service ----------------------------------*/
func (*Client) GetDeviceServicesByAddressableId ¶
func (c *Client) GetDeviceServicesByAddressableId(id string) ([]contract.DeviceService, error)
func (*Client) GetDeviceServicesWithLabel ¶
func (c *Client) GetDeviceServicesWithLabel(l string) ([]contract.DeviceService, error)
func (*Client) GetDevicesByProfileId ¶
func (*Client) GetDevicesByServiceId ¶
func (*Client) GetDevicesWithLabel ¶
func (Client) GetNewNormalNotifications ¶
func (c Client) GetNewNormalNotifications(limit int) ([]contract.Notification, error)
func (Client) GetNewNotifications ¶
func (c Client) GetNewNotifications(limit int) ([]contract.Notification, error)
func (Client) GetNotificationById ¶
func (c Client) GetNotificationById(id string) (notification contract.Notification, err error)
func (Client) GetNotificationBySender ¶
func (Client) GetNotificationBySlug ¶
func (c Client) GetNotificationBySlug(slug string) (notification contract.Notification, err error)
func (Client) GetNotifications ¶
func (c Client) GetNotifications() (n []contract.Notification, err error)
Get all notifications
func (Client) GetNotificationsByEnd ¶
func (Client) GetNotificationsByLabels ¶
func (Client) GetNotificationsByStart ¶
func (Client) GetNotificationsByStartEnd ¶
func (*Client) GetProvisionWatcherById ¶
func (c *Client) GetProvisionWatcherById(id string) (contract.ProvisionWatcher, error)
func (*Client) GetProvisionWatcherByName ¶
func (c *Client) GetProvisionWatcherByName(n string) (contract.ProvisionWatcher, error)
func (*Client) GetProvisionWatchersByIdentifier ¶
func (*Client) GetProvisionWatchersByProfileId ¶
func (c *Client) GetProvisionWatchersByProfileId(id string) ([]contract.ProvisionWatcher, error)
func (*Client) GetProvisionWatchersByServiceId ¶
func (c *Client) GetProvisionWatchersByServiceId(id string) ([]contract.ProvisionWatcher, error)
func (Client) GetSubscriptionByCategories ¶
func (c Client) GetSubscriptionByCategories(categories []string) (s []contract.Subscription, err error)
func (Client) GetSubscriptionByCategoriesLabels ¶
func (Client) GetSubscriptionById ¶
func (c Client) GetSubscriptionById(id string) (s contract.Subscription, err error)
func (Client) GetSubscriptionByLabels ¶
func (c Client) GetSubscriptionByLabels(labels []string) (s []contract.Subscription, err error)
func (Client) GetSubscriptionByReceiver ¶
func (c Client) GetSubscriptionByReceiver(receiver string) ([]contract.Subscription, error)
func (Client) GetSubscriptionBySlug ¶
func (c Client) GetSubscriptionBySlug(slug string) (s contract.Subscription, err error)
func (Client) GetSubscriptions ¶
func (c Client) GetSubscriptions() ([]contract.Subscription, error)
func (Client) GetTransmissionById ¶
func (c Client) GetTransmissionById(id string) (transmission contract.Transmission, err error)
func (Client) GetTransmissionsByEnd ¶
func (Client) GetTransmissionsByNotificationSlug ¶
func (Client) GetTransmissionsByNotificationSlugAndStartEnd ¶
func (Client) GetTransmissionsByStart ¶
func (Client) GetTransmissionsByStartEnd ¶
func (Client) GetTransmissionsByStatus ¶
func (c Client) GetTransmissionsByStatus(limit int, status contract.TransmissionStatus) (transmissions []contract.Transmission, err error)
func (*Client) IntervalActionById ¶
func (c *Client) IntervalActionById(id string) (action contract.IntervalAction, err error)
Get schedule interval action by id
func (*Client) IntervalActionByName ¶
func (c *Client) IntervalActionByName(name string) (action contract.IntervalAction, err error)
Get schedule interval action by name
func (*Client) IntervalActions ¶
func (c *Client) IntervalActions() (actions []contract.IntervalAction, err error)
Get all schedule interval action(s)
func (*Client) IntervalActionsByIntervalName ¶
func (c *Client) IntervalActionsByIntervalName(name string) (actions []contract.IntervalAction, err error)
Get all schedule interval action(s) by interval name
func (*Client) IntervalActionsByTarget ¶
func (c *Client) IntervalActionsByTarget(name string) (actions []contract.IntervalAction, err error)
Get all schedule interval action(s) by target name
func (*Client) IntervalActionsWithLimit ¶
func (c *Client) IntervalActionsWithLimit(limit int) (actions []contract.IntervalAction, err error)
Return schedule interval action(s) up to the number specified
func (*Client) IntervalById ¶
Return schedule interval by ID
func (*Client) IntervalByName ¶
Return schedule interval by name
func (*Client) IntervalsWithLimit ¶
Return schedule interval(s) up to the number specified
func (Client) MarkNotificationProcessed ¶
func (c Client) MarkNotificationProcessed(n contract.Notification) error
func (*Client) ReadingById ¶
Get a reading by ID
func (*Client) ReadingCount ¶
Get the number of readings in core data
func (*Client) Readings ¶
********************* READING FUNCTIONS ************************* Return a list of readings sorted by reading id
func (*Client) ReadingsByCreationTime ¶
func (c *Client) ReadingsByCreationTime(start, end int64, limit int) (readings []contract.Reading, err error)
Return a list of readings whos created time is between the start and end times
func (*Client) ReadingsByDevice ¶
Return a list of readings for the given device (id or name) 404 - meta data checking enabled and can't find the device Sort the list of readings on creation date
func (*Client) ReadingsByDeviceAndValueDescriptor ¶
func (c *Client) ReadingsByDeviceAndValueDescriptor(deviceId, valueDescriptor string, limit int) (readings []contract.Reading, err error)
Return a list of readings for a device filtered by the value descriptor and limited by the limit The readings are linked to the device through an event
func (*Client) ReadingsByValueDescriptor ¶
func (c *Client) ReadingsByValueDescriptor(name string, limit int) (readings []contract.Reading, err error)
Return a list of readings for the given value descriptor 413 - the number exceeds the current max limit
func (*Client) ReadingsByValueDescriptorNames ¶
func (c *Client) ReadingsByValueDescriptorNames(names []string, limit int) (readings []contract.Reading, err error)
Return a list of readings whose name is in the list of value descriptor names
func (*Client) ScrubAllEvents ¶
Delete all readings and events
func (*Client) ScrubAllIntervalActions ¶
Scrub all scheduler interval actions from the database data (only used in test)
func (*Client) ScrubAllIntervals ¶
Scrub all scheduler intervals from the database (only used in test)
func (*Client) ScrubAllValueDescriptors ¶
Delete all value descriptors
func (*Client) ScrubMetadata ¶
func (*Client) UpdateAddressable ¶
func (c *Client) UpdateAddressable(a contract.Addressable) error
-----------------------------------Addressable --------------------------
func (c *Client) UpdateAddressable(updated *contract.Addressable, orig *contract.Addressable) error {
func (*Client) UpdateDeviceProfile ¶
func (c *Client) UpdateDeviceProfile(dp contract.DeviceProfile) error
func (*Client) UpdateDeviceReport ¶
func (c *Client) UpdateDeviceReport(dr contract.DeviceReport) error
func (*Client) UpdateDeviceService ¶
func (c *Client) UpdateDeviceService(ds contract.DeviceService) error
func (*Client) UpdateEvent ¶
func (c *Client) UpdateEvent(e correlation.Event) (err error)
Update an event - do NOT update readings UnexpectedError - problem updating in database NotFound - no event with the ID was found
func (*Client) UpdateInterval ¶
Update a schedule interval
func (*Client) UpdateIntervalAction ¶
func (c *Client) UpdateIntervalAction(from contract.IntervalAction) (err error)
Update schedule interval action
func (Client) UpdateNotification ¶
func (c Client) UpdateNotification(n contract.Notification) error
func (*Client) UpdateProvisionWatcher ¶
func (c *Client) UpdateProvisionWatcher(pw contract.ProvisionWatcher) error
func (*Client) UpdateReading ¶
Update a reading 404 - reading cannot be found 409 - Value descriptor doesn't exist 503 - unknown issues
func (Client) UpdateSubscription ¶
func (c Client) UpdateSubscription(s contract.Subscription) error
func (Client) UpdateTransmission ¶
func (c Client) UpdateTransmission(t contract.Transmission) error
func (*Client) UpdateValueDescriptor ¶
func (c *Client) UpdateValueDescriptor(v contract.ValueDescriptor) error
Update a value descriptor First use the ID for identification, then the name TODO: Check for the valid printf formatting 404 not found if the value descriptor cannot be found by the identifiers
func (*Client) ValueDescriptorById ¶
func (c *Client) ValueDescriptorById(id string) (value contract.ValueDescriptor, err error)
Return a value descriptor based on the id
func (*Client) ValueDescriptorByName ¶
func (c *Client) ValueDescriptorByName(name string) (value contract.ValueDescriptor, err error)
Return a value descriptor based on the name
func (*Client) ValueDescriptors ¶
func (c *Client) ValueDescriptors() (values []contract.ValueDescriptor, err error)
Return a list of all the value descriptors 513 Service Unavailable - database problems
func (*Client) ValueDescriptorsByLabel ¶
func (c *Client) ValueDescriptorsByLabel(label string) (values []contract.ValueDescriptor, err error)
Return value descriptors based on the label
func (*Client) ValueDescriptorsByName ¶
func (c *Client) ValueDescriptorsByName(names []string) (values []contract.ValueDescriptor, err error)
Return value descriptors based on the names
func (*Client) ValueDescriptorsByType ¶
func (c *Client) ValueDescriptorsByType(t string) (values []contract.ValueDescriptor, err error)
Return a list of value descriptors based on their type
func (*Client) ValueDescriptorsByUomLabel ¶
func (c *Client) ValueDescriptorsByUomLabel(uomLabel string) (values []contract.ValueDescriptor, err error)
Return value descriptors based on the unit of measure label
type CoreDataClient ¶
type CoreDataClient struct { *Client // contains filtered or unexported fields }
func NewCoreDataClient ¶
func NewCoreDataClient(config db.Configuration, logger logger.LoggingClient) (*CoreDataClient, error)
func (*CoreDataClient) AsyncDeleteEvents ¶
func (c *CoreDataClient) AsyncDeleteEvents()
AsyncDeleteEvents Handles the deletion of device events asynchronously. This function is expected to be running in a go-routine and works with the "DeleteEventsByDevice" function for better performance.
func (*CoreDataClient) AsyncDeleteReadings ¶
func (c *CoreDataClient) AsyncDeleteReadings()
AsyncDeleteReadings Handles the deletion of device readings asynchronously. This function is expected to be running in a go-routine and works with the "DeleteReadingsByDevice" function for better performance.