Skip to content

Commit

Permalink
Merge pull request #950 from jinlinGuan/issue-947
Browse files Browse the repository at this point in the history
feat: change start/end from int to int64 for arm32
  • Loading branch information
cloudxxx8 authored Nov 19, 2024
2 parents c0ce723 + 2e32708 commit cc171c2
Show file tree
Hide file tree
Showing 16 changed files with 356 additions and 128 deletions.
4 changes: 2 additions & 2 deletions clients/http/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ func (ec *eventClient) DeleteByDeviceName(ctx context.Context, name string) (dto
return res, nil
}

func (ec *eventClient) EventsByTimeRange(ctx context.Context, start, end, offset, limit int) (
func (ec *eventClient) EventsByTimeRange(ctx context.Context, start, end int64, offset, limit int) (
responses.MultiEventsResponse, errors.EdgeX) {
requestPath := path.Join(common.ApiEventRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
requestPath := path.Join(common.ApiEventRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
requestParams := url.Values{}
requestParams.Set(common.Offset, strconv.Itoa(offset))
requestParams.Set(common.Limit, strconv.Itoa(limit))
Expand Down
6 changes: 3 additions & 3 deletions clients/http/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func TestDeleteEventsByDeviceName(t *testing.T) {
}

func TestQueryEventsByTimeRange(t *testing.T) {
start := 1
end := 10
urlPath := path.Join(common.ApiEventRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
start := int64(1)
end := int64(10)
urlPath := path.Join(common.ApiEventRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
ts := newTestServer(http.MethodGet, urlPath, responses.MultiEventsResponse{})
defer ts.Close()

Expand Down
4 changes: 2 additions & 2 deletions clients/http/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func (client *NotificationClient) NotificationsByStatus(ctx context.Context, sta
}

// NotificationsByTimeRange query notifications with time range, offset and limit
func (client *NotificationClient) NotificationsByTimeRange(ctx context.Context, start int, end int, offset int, limit int) (res responses.MultiNotificationsResponse, err errors.EdgeX) {
requestPath := path.Join(common.ApiNotificationRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
func (client *NotificationClient) NotificationsByTimeRange(ctx context.Context, start int64, end int64, offset int, limit int) (res responses.MultiNotificationsResponse, err errors.EdgeX) {
requestPath := path.Join(common.ApiNotificationRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
requestParams := url.Values{}
requestParams.Set(common.Offset, strconv.Itoa(offset))
requestParams.Set(common.Limit, strconv.Itoa(limit))
Expand Down
6 changes: 3 additions & 3 deletions clients/http/notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ func TestNotificationClient_NotificationsBySubscriptionName(t *testing.T) {
}

func TestNotificationClient_NotificationsByTimeRange(t *testing.T) {
start := 1
end := 10
urlPath := path.Join(common.ApiNotificationRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
start := int64(1)
end := int64(10)
urlPath := path.Join(common.ApiNotificationRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
ts := newTestServer(http.MethodGet, urlPath, responses.MultiNotificationsResponse{})
defer ts.Close()
client := NewNotificationClient(ts.URL, NewNullAuthenticationInjector(), false)
Expand Down
16 changes: 8 additions & 8 deletions clients/http/reading.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func (rc readingClient) ReadingsByResourceName(ctx context.Context, name string,
return res, nil
}

func (rc readingClient) ReadingsByTimeRange(ctx context.Context, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) {
requestPath := path.Join(common.ApiReadingRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
func (rc readingClient) ReadingsByTimeRange(ctx context.Context, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) {
requestPath := path.Join(common.ApiReadingRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
requestParams := url.Values{}
requestParams.Set(common.Offset, strconv.Itoa(offset))
requestParams.Set(common.Limit, strconv.Itoa(limit))
Expand All @@ -107,9 +107,9 @@ func (rc readingClient) ReadingsByTimeRange(ctx context.Context, start, end, off
}

// ReadingsByResourceNameAndTimeRange returns readings by resource name and specified time range. Readings are sorted in descending order of origin time.
func (rc readingClient) ReadingsByResourceNameAndTimeRange(ctx context.Context, name string, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) {
func (rc readingClient) ReadingsByResourceNameAndTimeRange(ctx context.Context, name string, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) {
requestPath := common.NewPathBuilder().EnableNameFieldEscape(rc.enableNameFieldEscape).
SetPath(common.ApiReadingRoute).SetPath(common.ResourceName).SetNameFieldPath(name).SetPath(common.Start).SetPath(strconv.Itoa(start)).SetPath(common.End).SetPath(strconv.Itoa(end)).BuildPath()
SetPath(common.ApiReadingRoute).SetPath(common.ResourceName).SetNameFieldPath(name).SetPath(common.Start).SetPath(strconv.FormatInt(start, 10)).SetPath(common.End).SetPath(strconv.FormatInt(end, 10)).BuildPath()
requestParams := url.Values{}
requestParams.Set(common.Offset, strconv.Itoa(offset))
requestParams.Set(common.Limit, strconv.Itoa(limit))
Expand All @@ -136,10 +136,10 @@ func (rc readingClient) ReadingsByDeviceNameAndResourceName(ctx context.Context,

}

func (rc readingClient) ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx context.Context, deviceName, resourceName string, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) {
func (rc readingClient) ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx context.Context, deviceName, resourceName string, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) {
requestPath := common.NewPathBuilder().EnableNameFieldEscape(rc.enableNameFieldEscape).
SetPath(common.ApiReadingRoute).SetPath(common.Device).SetPath(common.Name).SetNameFieldPath(deviceName).SetPath(common.ResourceName).SetNameFieldPath(resourceName).
SetPath(common.Start).SetPath(strconv.Itoa(start)).SetPath(common.End).SetPath(strconv.Itoa(end)).BuildPath()
SetPath(common.Start).SetPath(strconv.FormatInt(start, 10)).SetPath(common.End).SetPath(strconv.FormatInt(end, 10)).BuildPath()
requestParams := url.Values{}
requestParams.Set(common.Offset, strconv.Itoa(offset))
requestParams.Set(common.Limit, strconv.Itoa(limit))
Expand All @@ -151,10 +151,10 @@ func (rc readingClient) ReadingsByDeviceNameAndResourceNameAndTimeRange(ctx cont
return res, nil
}

func (rc readingClient) ReadingsByDeviceNameAndResourceNamesAndTimeRange(ctx context.Context, deviceName string, resourceNames []string, start, end, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) {
func (rc readingClient) ReadingsByDeviceNameAndResourceNamesAndTimeRange(ctx context.Context, deviceName string, resourceNames []string, start, end int64, offset, limit int) (responses.MultiReadingsResponse, errors.EdgeX) {
requestPath := common.NewPathBuilder().EnableNameFieldEscape(rc.enableNameFieldEscape).
SetPath(common.ApiReadingRoute).SetPath(common.Device).SetPath(common.Name).SetNameFieldPath(deviceName).
SetPath(common.Start).SetPath(strconv.Itoa(start)).SetPath(common.End).SetPath(strconv.Itoa(end)).BuildPath()
SetPath(common.Start).SetPath(strconv.FormatInt(start, 10)).SetPath(common.End).SetPath(strconv.FormatInt(end, 10)).BuildPath()
requestParams := url.Values{}
requestParams.Set(common.Offset, strconv.Itoa(offset))
requestParams.Set(common.Limit, strconv.Itoa(limit))
Expand Down
24 changes: 12 additions & 12 deletions clients/http/reading_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ func TestQueryReadingsByResourceName(t *testing.T) {
}

func TestQueryReadingsByTimeRange(t *testing.T) {
start := 1
end := 10
urlPath := path.Join(common.ApiReadingRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
start := int64(1)
end := int64(10)
urlPath := path.Join(common.ApiReadingRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
ts := newTestServer(http.MethodGet, urlPath, responses.MultiReadingsResponse{})
defer ts.Close()

Expand All @@ -92,9 +92,9 @@ func TestQueryReadingsByTimeRange(t *testing.T) {

func TestQueryReadingsByResourceNameAndTimeRange(t *testing.T) {
resourceName := "resource"
start := 1
end := 10
urlPath := path.Join(common.ApiReadingRoute, common.ResourceName, resourceName, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
start := int64(1)
end := int64(10)
urlPath := path.Join(common.ApiReadingRoute, common.ResourceName, resourceName, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
ts := newTestServer(http.MethodGet, urlPath, responses.MultiReadingsResponse{})
defer ts.Close()

Expand All @@ -120,9 +120,9 @@ func TestQueryReadingsByDeviceNameAndResourceName(t *testing.T) {
func TestQueryReadingsByDeviceNameAndResourceNameAndTimeRange(t *testing.T) {
deviceName := "device"
resourceName := "resource"
start := 1
end := 10
urlPath := path.Join(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.ResourceName, resourceName, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
start := int64(1)
end := int64(10)
urlPath := path.Join(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.ResourceName, resourceName, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
ts := newTestServer(http.MethodGet, urlPath, responses.MultiReadingsResponse{})
defer ts.Close()

Expand All @@ -135,9 +135,9 @@ func TestQueryReadingsByDeviceNameAndResourceNameAndTimeRange(t *testing.T) {
func TestQueryReadingsByDeviceNameAndResourceNamesAndTimeRange(t *testing.T) {
deviceName := "device"
resourceNames := []string{"resource01", "resource02"}
start := 1
end := 10
urlPath := path.Join(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
start := int64(1)
end := int64(10)
urlPath := path.Join(common.ApiReadingRoute, common.Device, common.Name, deviceName, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
ts := newTestServer(http.MethodGet, urlPath, responses.MultiReadingsResponse{})
defer ts.Close()

Expand Down
4 changes: 2 additions & 2 deletions clients/http/transmission.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func (client *TransmissionClient) TransmissionById(ctx context.Context, id strin
}

// TransmissionsByTimeRange query transmissions with time range, offset and limit
func (client *TransmissionClient) TransmissionsByTimeRange(ctx context.Context, start int, end int, offset int, limit int) (res responses.MultiTransmissionsResponse, err errors.EdgeX) {
requestPath := path.Join(common.ApiTransmissionRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
func (client *TransmissionClient) TransmissionsByTimeRange(ctx context.Context, start int64, end int64, offset int, limit int) (res responses.MultiTransmissionsResponse, err errors.EdgeX) {
requestPath := path.Join(common.ApiTransmissionRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
requestParams := url.Values{}
requestParams.Set(common.Offset, strconv.Itoa(offset))
requestParams.Set(common.Limit, strconv.Itoa(limit))
Expand Down
6 changes: 3 additions & 3 deletions clients/http/transmission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func TestTransmissionClient_TransmissionsBySubscriptionName(t *testing.T) {
}

func TestTransmissionClient_TransmissionsByTimeRange(t *testing.T) {
start := 1
end := 10
urlPath := path.Join(common.ApiTransmissionRoute, common.Start, strconv.Itoa(start), common.End, strconv.Itoa(end))
start := int64(1)
end := int64(10)
urlPath := path.Join(common.ApiTransmissionRoute, common.Start, strconv.FormatInt(start, 10), common.End, strconv.FormatInt(end, 10))
ts := newTestServer(http.MethodGet, urlPath, responses.MultiTransmissionsResponse{})
defer ts.Close()
client := NewTransmissionClient(ts.URL, NewNullAuthenticationInjector(), false)
Expand Down
2 changes: 1 addition & 1 deletion clients/interfaces/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type EventClient interface {
// start, end: Unix timestamp, indicating the date/time range.
// offset: The number of items to skip before starting to collect the result set. Default is 0.
// limit: The number of items to return. Specify -1 will return all remaining items after offset. The maximum will be the MaxResultCount as defined in the configuration of service. Default is 20.
EventsByTimeRange(ctx context.Context, start, end, offset, limit int) (responses.MultiEventsResponse, errors.EdgeX)
EventsByTimeRange(ctx context.Context, start, end int64, offset, limit int) (responses.MultiEventsResponse, errors.EdgeX)
// DeleteByAge deletes events that are older than the given age. Age is supposed in milliseconds from created timestamp.
DeleteByAge(ctx context.Context, age int) (common.BaseResponse, errors.EdgeX)
// DeleteById deletes an event by its id
Expand Down
Loading

0 comments on commit cc171c2

Please sign in to comment.