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 eafbf3d
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 196 deletions.
13 changes: 1 addition & 12 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 @@ -312,10 +311,8 @@ void edgex_device_parseTomlClients
{
if (clients)
{
parseClient (lc, toml_table_in (clients, "core-data"), &endpoints->data, err);
parseClient (lc, toml_table_in (clients, "core-metadata"), &endpoints->metadata, err);
}
checkClientOverride (lc, "CORE_DATA", &endpoints->data);
checkClientOverride (lc, "CORE_METADATA", &endpoints->metadata);
}

Expand Down Expand Up @@ -696,7 +693,6 @@ void edgex_device_freeConfig (devsdk_service_t *svc)
free (svc->config.service.labels);
}

free (svc->config.endpoints.data.host);
free (svc->config.endpoints.metadata.host);

iot_data_free (svc->config.sdkconf);
Expand Down Expand Up @@ -745,7 +741,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 Expand Up @@ -781,12 +776,6 @@ static JSON_Value *edgex_device_config_toJson (devsdk_service_t *svc)
json_object_set_uint (mobj, "Port", svc->config.endpoints.metadata.port);
json_object_set_value (cobj, "Metadata", mval);

dval = json_value_init_object ();
dobj = json_value_get_object (dval);
json_object_set_string (dobj, "Host", svc->config.endpoints.data.host);
json_object_set_uint (dobj, "Port", svc->config.endpoints.data.port);
json_object_set_value (cobj, "Data", dval);

json_object_set_value (obj, "Clients", cval);

mval = json_value_init_object ();
Expand Down
3 changes: 1 addition & 2 deletions src/c/config.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 @@ -42,7 +42,6 @@ typedef struct edgex_device_service_endpoint

typedef struct edgex_service_endpoints
{
edgex_device_service_endpoint data;
edgex_device_service_endpoint metadata;
} edgex_service_endpoints;

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
Loading

0 comments on commit eafbf3d

Please sign in to comment.