Skip to content

Commit

Permalink
refactor!: remove legacy metrics api, event publishing to core-data
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removed the Device.UseMessageBus config
and the code for sending event via core-data REST client
(MessageBus is always enabled in 3.0 for sending events)
BREAKING CHANGE: v2 metrics endpoint is removed for all services

Signed-off-by: Iain Anderson <[email protected]>
  • Loading branch information
iain-anderson committed Feb 7, 2023
1 parent 60c7205 commit 781a83b
Show file tree
Hide file tree
Showing 16 changed files with 174 additions and 185 deletions.
4 changes: 1 addition & 3 deletions src/c/config.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2022
* Copyright (c) 2018-2023
* IoTech Ltd
*
* SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -87,7 +87,6 @@ iot_data_t *edgex_config_defaults (const iot_data_t *driverconf, const char *svc
iot_data_string_map_add (result, "Service/CORSConfiguration/CORSMaxAge", iot_data_alloc_ui32 (3600));

iot_data_string_map_add (result, "Device/Labels", iot_data_alloc_string ("", IOT_DATA_REF));
iot_data_string_map_add (result, "Device/UseMessageBus", iot_data_alloc_bool (false));
iot_data_string_map_add (result, "Device/ProfilesDir", iot_data_alloc_string ("", IOT_DATA_REF));
iot_data_string_map_add (result, "Device/DevicesDir", iot_data_alloc_string ("", IOT_DATA_REF));
iot_data_string_map_add (result, "Device/EventQLength", iot_data_alloc_ui32 (0));
Expand Down Expand Up @@ -745,7 +744,6 @@ static JSON_Value *edgex_device_config_toJson (devsdk_service_t *svc)
json_object_set_boolean
(dobj, "UpdateLastConnected", svc->config.device.updatelastconnected);
json_object_set_uint (dobj, "EventQLength", svc->config.device.eventqlen);
json_object_set_boolean (dobj, "UseMessageBus", iot_data_string_map_get_bool (svc->config.sdkconf, "Device/UseMessageBus", false));

JSON_Value *lval = json_value_init_array ();
JSON_Array *larr = json_value_get_array (lval);
Expand Down
59 changes: 0 additions & 59 deletions src/c/data-rest.c

This file was deleted.

17 changes: 0 additions & 17 deletions src/c/data-rest.h

This file was deleted.

4 changes: 1 addition & 3 deletions src/c/data.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020
* Copyright (c) 2018-2023
* IoTech Ltd
*
* SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -84,8 +84,6 @@ typedef struct edgex_data_client_t

typedef struct edgex_device_service_endpoint edgex_device_service_endpoint;

edgex_data_client_t *edgex_data_client_new_rest (const edgex_device_service_endpoint *e, iot_logger_t *lc, iot_threadpool_t *queue);

void edgex_data_client_free (edgex_data_client_t *client);

void edgex_data_client_add_event (edgex_data_client_t *client, edgex_event_cooked *eventval, devsdk_metrics_t *metrics);
Expand Down
18 changes: 18 additions & 0 deletions src/c/examples/bitfields/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,21 @@
Labels = [ "Bitfields" ]
ProfilesDir = "res/profiles"
DevicesDir = "res/devices"

[MessageBus]
Protocol = "redis"
Host = "localhost"
Port = 6379
Type = "redis"
AuthMode = "usernamepassword" # required for redis messagebus (secure or insecure)
SecretName = "redisdb"
[MessageBus.Optional]
ClientId = "device-bitfields"
Qos = 0 # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = 10 # Seconds (must be 2 or greater)
Retained = false
SkipCertVerify = false
[MessageBus.Topics]
PublishTopicPrefix = "edgex/events/device" # /<device-profile-name>/<device-name>/<source-name> will be added to this Publish Topic prefix
CommandRequestTopic = "edgex/device/command/request/device-bacnet/#" # subscribing for inbound command requests
CommandResponseTopicPrefix = "edgex/device/command/response" # publishing outbound command responses; <device-service>/<device-name>/<command-name>/<method> will be added to this publish topic prefix
18 changes: 18 additions & 0 deletions src/c/examples/counters/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,21 @@
Labels = [ "Counter" ]
ProfilesDir = "res/profiles"
DevicesDir = "res/devices"

[MessageBus]
Protocol = "redis"
Host = "localhost"
Port = 6379
Type = "redis"
AuthMode = "usernamepassword" # required for redis messagebus (secure or insecure)
SecretName = "redisdb"
[MessageBus.Optional]
ClientId = "device-counters"
Qos = 0 # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = 10 # Seconds (must be 2 or greater)
Retained = false
SkipCertVerify = false
[MessageBus.Topics]
PublishTopicPrefix = "edgex/events/device" # /<device-profile-name>/<device-name>/<source-name> will be added to this Publish Topic prefix
CommandRequestTopic = "edgex/device/command/request/device-bacnet/#" # subscribing for inbound command requests
CommandResponseTopicPrefix = "edgex/device/command/response" # publishing outbound command responses; <device-service>/<device-name>/<command-name>/<method> will be added to this publish topic prefix
18 changes: 18 additions & 0 deletions src/c/examples/discovery/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,21 @@
Labels = [ "Template" ]
ProfilesDir = "res/profiles"
DevicesDir = "res/devices"

[MessageBus]
Protocol = "redis"
Host = "localhost"
Port = 6379
Type = "redis"
AuthMode = "usernamepassword" # required for redis messagebus (secure or insecure)
SecretName = "redisdb"
[MessageBus.Optional]
ClientId = "device-discovery"
Qos = 0 # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = 10 # Seconds (must be 2 or greater)
Retained = false
SkipCertVerify = false
[MessageBus.Topics]
PublishTopicPrefix = "edgex/events/device" # /<device-profile-name>/<device-name>/<source-name> will be added to this Publish Topic prefix
CommandRequestTopic = "edgex/device/command/request/device-bacnet/#" # subscribing for inbound command requests
CommandResponseTopicPrefix = "edgex/device/command/response" # publishing outbound command responses; <device-service>/<device-name>/<command-name>/<method> will be added to this publish topic prefix
18 changes: 18 additions & 0 deletions src/c/examples/file/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,21 @@
[Device]
ProfilesDir = "res/profiles"
DevicesDir = "res/devices"

[MessageBus]
Protocol = "redis"
Host = "localhost"
Port = 6379
Type = "redis"
AuthMode = "usernamepassword" # required for redis messagebus (secure or insecure)
SecretName = "redisdb"
[MessageBus.Optional]
ClientId = "device-file"
Qos = 0 # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = 10 # Seconds (must be 2 or greater)
Retained = false
SkipCertVerify = false
[MessageBus.Topics]
PublishTopicPrefix = "edgex/events/device" # /<device-profile-name>/<device-name>/<source-name> will be added to this Publish Topic prefix
CommandRequestTopic = "edgex/device/command/request/device-bacnet/#" # subscribing for inbound command requests
CommandResponseTopicPrefix = "edgex/device/command/response" # publishing outbound command responses; <device-service>/<device-name>/<command-name>/<method> will be added to this publish topic prefix
18 changes: 18 additions & 0 deletions src/c/examples/gyro/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,21 @@
Labels = [ "Gyro" ]
ProfilesDir = "res/profiles"
DevicesDir = "res/devices"

[MessageBus]
Protocol = "redis"
Host = "localhost"
Port = 6379
Type = "redis"
AuthMode = "usernamepassword" # required for redis messagebus (secure or insecure)
SecretName = "redisdb"
[MessageBus.Optional]
ClientId = "device-gyro"
Qos = 0 # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = 10 # Seconds (must be 2 or greater)
Retained = false
SkipCertVerify = false
[MessageBus.Topics]
PublishTopicPrefix = "edgex/events/device" # /<device-profile-name>/<device-name>/<source-name> will be added to this Publish Topic prefix
CommandRequestTopic = "edgex/device/command/request/device-bacnet/#" # subscribing for inbound command requests
CommandResponseTopicPrefix = "edgex/device/command/response" # publishing outbound command responses; <device-service>/<device-name>/<command-name>/<method> will be added to this publish topic prefix
18 changes: 18 additions & 0 deletions src/c/examples/random/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,21 @@
Labels = [ "Random" ]
ProfilesDir = "res/profiles"
DevicesDir = "res/devices"

[MessageBus]
Protocol = "redis"
Host = "localhost"
Port = 6379
Type = "redis"
AuthMode = "usernamepassword" # required for redis messagebus (secure or insecure)
SecretName = "redisdb"
[MessageBus.Optional]
ClientId = "device-random"
Qos = 0 # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = 10 # Seconds (must be 2 or greater)
Retained = false
SkipCertVerify = false
[MessageBus.Topics]
PublishTopicPrefix = "edgex/events/device" # /<device-profile-name>/<device-name>/<source-name> will be added to this Publish Topic prefix
CommandRequestTopic = "edgex/device/command/request/device-bacnet/#" # subscribing for inbound command requests
CommandResponseTopicPrefix = "edgex/device/command/response" # publishing outbound command responses; <device-service>/<device-name>/<command-name>/<method> will be added to this publish topic prefix
18 changes: 18 additions & 0 deletions src/c/examples/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,21 @@
Labels = [ "Template" ]
ProfilesDir = "res/profiles"
DevicesDir = "res/devices"

[MessageBus]
Protocol = "redis"
Host = "localhost"
Port = 6379
Type = "redis"
AuthMode = "usernamepassword" # required for redis messagebus (secure or insecure)
SecretName = "redisdb"
[MessageBus.Optional]
ClientId = "device-template"
Qos = 0 # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = 10 # Seconds (must be 2 or greater)
Retained = false
SkipCertVerify = false
[MessageBus.Topics]
PublishTopicPrefix = "edgex/events/device" # /<device-profile-name>/<device-name>/<source-name> will be added to this Publish Topic prefix
CommandRequestTopic = "edgex/device/command/request/device-bacnet/#" # subscribing for inbound command requests
CommandResponseTopicPrefix = "edgex/device/command/response" # publishing outbound command responses; <device-service>/<device-name>/<command-name>/<method> will be added to this publish topic prefix
18 changes: 18 additions & 0 deletions src/c/examples/terminal/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,21 @@
Labels = [ "Counter" ]
ProfilesDir = "res/profiles"
DevicesDir = "res/devices"

[MessageBus]
Protocol = "redis"
Host = "localhost"
Port = 6379
Type = "redis"
AuthMode = "usernamepassword" # required for redis messagebus (secure or insecure)
SecretName = "redisdb"
[MessageBus.Optional]
ClientId = "device-terminal"
Qos = 0 # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = 10 # Seconds (must be 2 or greater)
Retained = false
SkipCertVerify = false
[MessageBus.Topics]
PublishTopicPrefix = "edgex/events/device" # /<device-profile-name>/<device-name>/<source-name> will be added to this Publish Topic prefix
CommandRequestTopic = "edgex/device/command/request/device-bacnet/#" # subscribing for inbound command requests
CommandResponseTopicPrefix = "edgex/device/command/response" # publishing outbound command responses; <device-service>/<device-name>/<command-name>/<method> will be added to this publish topic prefix
64 changes: 0 additions & 64 deletions src/c/metrics.c

This file was deleted.

5 changes: 1 addition & 4 deletions src/c/metrics.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019
* Copyright (c) 2019-2023
* IoTech Ltd
*
* SPDX-License-Identifier: Apache-2.0
Expand All @@ -10,9 +10,6 @@
#define _EDGEX_DEVICE_METRICS_H_ 1

#include <stdatomic.h>
#include "rest-server.h"

extern void edgex_device_handler_metricsv2 (void *ctx, const devsdk_http_request *req, devsdk_http_reply *reply);

typedef struct devsdk_metrics_t
{
Expand Down
Loading

0 comments on commit 781a83b

Please sign in to comment.