Skip to content

Commit

Permalink
feat!: Remove LastConnected, LastReported and UpdateLastConnected con…
Browse files Browse the repository at this point in the history
…figs

BREAKING CHANGE: Remove LastConnected, LastReported and UpdateLastConnected configs

Signed-off-by: Ginny Guan <ginny@iotechsys.com>
  • Loading branch information
jinlinGuan committed Feb 17, 2023
1 parent bf4aa2d commit 7414f7f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 39 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/OneOfOne/xxhash v1.2.8
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.24
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.16
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.18
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.9
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.3
github.com/google/uuid v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.24 h1:H9MC0ahbkMw4w1SHeX6
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.24/go.mod h1:iv/czxi4ciFWMgrO+3nnanGfkT2X1QW5L3iCb+deewk=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.3 h1:0Ew4PzLSFJ+sb7AYtvb9m1mRN45Sh0ELU1HdMCel5t8=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.3/go.mod h1:ESOWI4GokQfQ3Bn2hGsdfOVx5idj7QEdCPT/SAQDd9M=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.16 h1:pXq48wY3E7QHSOQjEtoZX/zC7GEH4gGrRzsYOr0MDkg=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.16/go.mod h1:4lpZUM54ZareGU/yuAJvLEw0BoJ43SvCj1LO+gsKm9c=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.18 h1:98BcSFWiuTYSls25hX73l0mDNNgh3Sd7L5mhLj6maG0=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.18/go.mod h1:4lpZUM54ZareGU/yuAJvLEw0BoJ43SvCj1LO+gsKm9c=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.9 h1:CUUieXQ8roD4M770GXj1he707V3V9Jiygk302+dwvKk=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.9/go.mod h1:iKBxmZkc7jdOrT99+IR1nyg7PlRgooAQMhZxDh2mTUQ=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.3 h1:QgZF9f70Cwpvkjw3tP1aiVGHc+yNFJNzW6hO8pDs3fg=
Expand Down
7 changes: 0 additions & 7 deletions internal/application/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ func GetCommand(ctx context.Context, deviceName string, commandName string, quer
return nil, errors.NewCommonEdgeXWrapper(err)
}

configuration := container.ConfigurationFrom(dic.Get)
if configuration.Device.UpdateLastConnected {
lc := bootstrapContainer.LoggingClientFrom(dic.Get)
dc := bootstrapContainer.DeviceClientFrom(dic.Get)
go sdkCommon.UpdateLastConnected(device.Name, lc, dc)
}

lc := bootstrapContainer.LoggingClientFrom(dic.Get)
lc.Debugf("GET Device Command successfully. Device: %s, Source: %s, %s: %s", deviceName, commandName, common.CorrelationHeader, utils.FromContext(ctx, common.CorrelationHeader))
return res, nil
Expand Down
16 changes: 0 additions & 16 deletions internal/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ package common

import (
"context"
"time"

"github.com/edgexfoundry/device-sdk-go/v3/internal/cache"
"github.com/edgexfoundry/device-sdk-go/v3/internal/container"

Expand All @@ -37,20 +35,6 @@ const (
var eventsSent gometrics.Counter
var readingsSent gometrics.Counter

func UpdateLastConnected(name string, lc logger.LoggingClient, dc interfaces.DeviceClient) {
t := time.Now().UnixNano() / int64(time.Millisecond)
device := dtos.UpdateDevice{
Name: &name,
LastConnected: &t,
}

req := requests.NewUpdateDeviceRequest(device)
_, err := dc.Update(context.Background(), []requests.UpdateDeviceRequest{req})
if err != nil {
lc.Errorf("failed to update LastConnected for Device %s in Core Metadata: %v", name, err)
}
}

func UpdateOperatingState(name string, state string, lc logger.LoggingClient, dc interfaces.DeviceClient) {
device := dtos.UpdateDevice{
Name: &name,
Expand Down
6 changes: 1 addition & 5 deletions internal/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ type DeviceInfo struct {
DevicesDir string
// ProvisionWatchersDir specifies a directory contains provision watcher files which should be imported on startup.
ProvisionWatchersDir string
// UpdateLastConnected specifies whether to update device's LastConnected
// timestamp in metadata.
UpdateLastConnected bool

Discovery DiscoveryInfo
Discovery DiscoveryInfo
// AsyncBufferSize defines the size of asynchronous channel
AsyncBufferSize int
// EnableAsyncReadings to determine whether the Device Service would deal with the asynchronous readings
Expand Down
10 changes: 2 additions & 8 deletions openapi/v3/device-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ components:
apiVersion:
description: "A version number shows the API version in DTOs."
type: string
example: "v2"
example: "v3"
BaseResponse:
description: "Defines basic properties which all use-case specific response DTO instances should support"
type: object
properties:
apiVersion:
description: "A version number shows the API version in DTOs."
type: string
example: "v2"
example: "v3"
requestId:
description: "Uniquely identifies the request that resulted in this response."
type: string
Expand Down Expand Up @@ -87,12 +87,6 @@ components:
type: string
enum: [UP, DOWN, UNKNOWN]
description: "Operating state of the device, indicating whether it is currently responsive"
lastConnected:
type: integer
description: "Time (milliseconds) that the device last provided any feedback or responded to any request"
lastReported:
type: integer
description: "Time (milliseconds) that the device reported data to the core microservice"
labels:
type: array
items:
Expand Down

0 comments on commit 7414f7f

Please sign in to comment.