redis

package
v1.2.2-dev.32 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

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

View Source
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

func (c *Client) AddDevice(d contract.Device, commands []contract.Command) (string, error)

/* ----------------------------- 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

func (c *Client) AddInterval(from contract.Interval) (id string, err error)

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

func (c *Client) AddReading(r contract.Reading) (id string, err error)

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) Cleanup

func (c Client) Cleanup() error

Cleanup delete all notifications and associated transmissions

func (Client) CleanupOld

func (c Client) CleanupOld(age int) error

Cleanup delete old notifications and associated transmissions

func (*Client) CloseSession

func (c *Client) CloseSession()

CloseSession closes the connections to Redis

func (*Client) Connect

func (c *Client) Connect() error

Connect connects to Redis

func (*Client) DeleteAddressableById

func (c *Client) DeleteAddressableById(id string) error

func (*Client) DeleteDeviceById

func (c *Client) DeleteDeviceById(id string) error

func (*Client) DeleteDeviceProfileById

func (c *Client) DeleteDeviceProfileById(id string) error

func (*Client) DeleteDeviceReportById

func (c *Client) DeleteDeviceReportById(id string) error

func (*Client) DeleteDeviceServiceById

func (c *Client) DeleteDeviceServiceById(id string) error

func (*Client) DeleteEventById

func (c *Client) DeleteEventById(id string) error

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

func (c *Client) DeleteEventsByDevice(deviceId string) (int, error)

DeleteEventsByDevice Delete events and readings associated with the specified deviceID

func (*Client) DeleteIntervalActionById

func (c *Client) DeleteIntervalActionById(id string) (err error)

Remove schedule interval action by id

func (*Client) DeleteIntervalById

func (c *Client) DeleteIntervalById(id string) (err error)

Remove schedule interval by ID

func (Client) DeleteNotificationById

func (c Client) DeleteNotificationById(id string) error

func (Client) DeleteNotificationBySlug

func (c Client) DeleteNotificationBySlug(slug string) error

func (Client) DeleteNotificationsOld

func (c Client) DeleteNotificationsOld(age int) error

DeleteNotificationsOld remove all the notifications that are older than the given age

func (*Client) DeleteProvisionWatcherById

func (c *Client) DeleteProvisionWatcherById(id string) error

func (*Client) DeleteReadingById

func (c *Client) DeleteReadingById(id string) error

Delete a reading by ID 404 - can't find the reading with the given id

func (*Client) DeleteReadingsByDevice

func (c *Client) DeleteReadingsByDevice(device string) error

DeleteReadingsByDevice deletes readings associated with the specified device

func (*Client) DeleteSubscriptionById

func (c *Client) DeleteSubscriptionById(id string) error

func (Client) DeleteSubscriptionBySlug

func (c Client) DeleteSubscriptionBySlug(slug string) error

func (Client) DeleteTransmission

func (c Client) DeleteTransmission(age int64, status contract.TransmissionStatus) error

DeleteTransmission delete old transmission with specified status

func (*Client) DeleteValueDescriptorById

func (c *Client) DeleteValueDescriptorById(id string) error

Delete a value descriptor based on the ID

func (*Client) EventById

func (c *Client) EventById(id string) (event contract.Event, err error)

Get an event by id

func (*Client) EventCount

func (c *Client) EventCount() (count int, err error)

Get the number of events in Core Data

func (*Client) EventCountByDeviceId

func (c *Client) EventCountByDeviceId(id string) (count int, err error)

Get the number of events in Core Data for the device specified by id

func (*Client) Events

func (c *Client) Events() (events []contract.Event, err error)

********************** 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

func (c *Client) EventsByChecksum(checksum string) (events []contract.Event, err error)

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

func (c *Client) EventsForDevice(id string) (events []contract.Event, err error)

Get a list of events based on the device id

func (*Client) EventsForDeviceLimit

func (c *Client) EventsForDeviceLimit(id string, limit int) (events []contract.Event, err error)

Get a list of events based on the device id and limit

func (*Client) EventsOlderThanAge

func (c *Client) EventsOlderThanAge(age int64) ([]contract.Event, error)

Get events that are older than a age

func (*Client) EventsPushed

func (c *Client) EventsPushed() (events []contract.Event, err error)

Get events that have been pushed (pushed field is not 0)

func (*Client) EventsWithLimit

func (c *Client) EventsWithLimit(limit int) (events []contract.Event, err error)

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

func (c *Client) GetAllCommands() ([]contract.Command, error)

------------------------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) GetAllDevices

func (c *Client) GetAllDevices() ([]contract.Device, error)

func (*Client) GetAllProvisionWatchers

func (c *Client) GetAllProvisionWatchers() ([]contract.ProvisionWatcher, error)

----------------------Provision Watcher -----------------------------*/

func (*Client) GetCommandById

func (c *Client) GetCommandById(id string) (contract.Command, error)

func (*Client) GetCommandByNameAndDeviceId

func (c *Client) GetCommandByNameAndDeviceId(cname string, did string) (contract.Command, error)

func (*Client) GetCommandsByDeviceId

func (c *Client) GetCommandsByDeviceId(did string) ([]contract.Command, error)

func (*Client) GetCommandsByName

func (c *Client) GetCommandsByName(n string) ([]contract.Command, error)

func (*Client) GetDeviceById

func (c *Client) GetDeviceById(id string) (contract.Device, error)

func (*Client) GetDeviceByName

func (c *Client) GetDeviceByName(n string) (contract.Device, error)

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 (c *Client) GetDeviceProfilesByManufacturerModel(man string, mod string) ([]contract.DeviceProfile, error)

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 (c *Client) GetDevicesByProfileId(id string) ([]contract.Device, error)

func (*Client) GetDevicesByServiceId

func (c *Client) GetDevicesByServiceId(id string) ([]contract.Device, error)

func (*Client) GetDevicesWithLabel

func (c *Client) GetDevicesWithLabel(l string) ([]contract.Device, error)

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 (c Client) GetNotificationBySender(sender string, limit int) ([]contract.Notification, error)

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 (c Client) GetNotificationsByEnd(end int64, limit int) ([]contract.Notification, error)

func (Client) GetNotificationsByLabels

func (c Client) GetNotificationsByLabels(labels []string, limit int) (notifications []contract.Notification, err error)

func (Client) GetNotificationsByStart

func (c Client) GetNotificationsByStart(start int64, limit int) ([]contract.Notification, error)

func (Client) GetNotificationsByStartEnd

func (c Client) GetNotificationsByStartEnd(start int64, end int64, limit int) ([]contract.Notification, error)

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 (c *Client) GetProvisionWatchersByIdentifier(k string, v string) (pw []contract.ProvisionWatcher, err error)

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 (c Client) GetSubscriptionByCategoriesLabels(categories []string, labels []string) (s []contract.Subscription, err error)

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 (c Client) GetTransmissionsByEnd(end int64, limit int) (transmissions []contract.Transmission, err error)

func (Client) GetTransmissionsByNotificationSlug

func (c Client) GetTransmissionsByNotificationSlug(slug string, limit int) (transmissions []contract.Transmission, err error)

func (Client) GetTransmissionsByNotificationSlugAndStartEnd

func (c Client) GetTransmissionsByNotificationSlugAndStartEnd(slug string, start int64, end int64, limit int) (transmissions []contract.Transmission, err error)

func (Client) GetTransmissionsByStart

func (c Client) GetTransmissionsByStart(start int64, limit int) (transmissions []contract.Transmission, err error)

func (Client) GetTransmissionsByStartEnd

func (c Client) GetTransmissionsByStartEnd(start int64, end int64, limit int) (transmissions []contract.Transmission, err error)

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

func (c *Client) IntervalById(id string) (interval contract.Interval, err error)

Return schedule interval by ID

func (*Client) IntervalByName

func (c *Client) IntervalByName(name string) (interval contract.Interval, err error)

Return schedule interval by name

func (*Client) Intervals

func (c *Client) Intervals() (intervals []contract.Interval, err error)

Return all the schedule interval(s)

func (*Client) IntervalsWithLimit

func (c *Client) IntervalsWithLimit(limit int) (intervals []contract.Interval, err error)

Return schedule interval(s) up to the number specified

func (Client) MarkNotificationProcessed

func (c Client) MarkNotificationProcessed(n contract.Notification) error

func (*Client) ReadingById

func (c *Client) ReadingById(id string) (reading contract.Reading, err error)

Get a reading by ID

func (*Client) ReadingCount

func (c *Client) ReadingCount() (int, error)

Get the number of readings in core data

func (*Client) Readings

func (c *Client) Readings() (readings []contract.Reading, err error)

********************* 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

func (c *Client) ReadingsByDevice(id string, limit int) (readings []contract.Reading, err error)

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

func (c *Client) ScrubAllEvents() (err error)

Delete all readings and events

func (*Client) ScrubAllIntervalActions

func (c *Client) ScrubAllIntervalActions() (count int, err error)

Scrub all scheduler interval actions from the database data (only used in test)

func (*Client) ScrubAllIntervals

func (c *Client) ScrubAllIntervals() (count int, err error)

Scrub all scheduler intervals from the database (only used in test)

func (*Client) ScrubAllValueDescriptors

func (c *Client) ScrubAllValueDescriptors() error

Delete all value descriptors

func (*Client) ScrubMetadata

func (c *Client) ScrubMetadata() (err error)

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) UpdateDevice

func (c *Client) UpdateDevice(d contract.Device) 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

func (c *Client) UpdateInterval(from contract.Interval) (err error)

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

func (c *Client) UpdateReading(r contract.Reading) error

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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