Skip to content

Commit

Permalink
fix typos in public API
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenmiller committed Jan 17, 2024
1 parent af63511 commit 07ecd4e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions pkg/c8y/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ import (

const TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"

type Cachable func(*http.Request) bool
type Cacheable func(*http.Request) bool

func NewCachedClient(httpClient *http.Client, cacheDir string, cacheTTL time.Duration, isCachable Cachable, opts CacheOptions) *http.Client {
func NewCachedClient(httpClient *http.Client, cacheDir string, cacheTTL time.Duration, isCacheable Cacheable, opts CacheOptions) *http.Client {
if cacheDir == "" {
cacheDir = filepath.Join(os.TempDir(), "go-c8y-cache")
}
if isCachable == nil {
isCachable = isCacheableRequest
if isCacheable == nil {
isCacheable = isCacheableRequest
}
return &http.Client{
Transport: CacheResponse(cacheTTL, cacheDir, isCachable, opts)(httpClient.Transport),
Transport: CacheResponse(cacheTTL, cacheDir, isCacheable, opts)(httpClient.Transport),
}
}

Expand All @@ -50,7 +50,7 @@ func isCacheableResponse(res *http.Response) bool {
}

// CacheResponse produces a RoundTripper that caches HTTP responses to disk for a specified amount of time
func CacheResponse(ttl time.Duration, dir string, isCachable Cachable, options CacheOptions) ClientOption {
func CacheResponse(ttl time.Duration, dir string, isCacheable Cacheable, options CacheOptions) ClientOption {
fs := fileStorage{
dir: dir,
ttl: ttl,
Expand All @@ -60,7 +60,7 @@ func CacheResponse(ttl time.Duration, dir string, isCachable Cachable, options C
return func(tr http.RoundTripper) http.RoundTripper {
return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {

if !isCachable(req) {
if !isCacheable(req) {
return tr.RoundTrip(req)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/c8y/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1217,9 +1217,9 @@ type ErrorResponse struct {

// Error details. Only available in DEBUG mode.
Details *struct {
ExpectionClass string `json:"expectionClass,omitempty"`
ExceptionClass string `json:"exceptionClass,omitempty"`
ExceptionMessage string `json:"exceptionMessage,omitempty"`
ExpectionStackTrace string `json:"expectionStackTrace,omitempty"`
ExceptionStackTrace string `json:"exceptionStackTrace,omitempty"`
} `json:"details,omitempty"`
}

Expand Down
28 changes: 14 additions & 14 deletions pkg/c8y/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ func (s *MeasurementService) DeleteMeasurements(ctx context.Context, opt *Measur
})
}

// MeasurementSerieDefinition represents information about a serie
type MeasurementSerieDefinition struct {
// MeasurementSeriesDefinition represents information about a single series
type MeasurementSeriesDefinition struct {
Unit string `json:"unit"`
Name string `json:"name"`
Type string `json:"type"`
Expand All @@ -112,7 +112,7 @@ type MeasurementSeriesAggregateValueGroup struct {
// MeasurementSeriesGroup represents a group of series values (no aggregate values)
type MeasurementSeriesGroup struct {
DeviceID string `json:"deviceId"`
Series []MeasurementSerieDefinition `json:"series"`
Series []MeasurementSeriesDefinition `json:"series"`
Values []MeasurementSeriesValueGroup `json:"values"`
DateFrom time.Time `json:"dateFrom"`
DateTo time.Time `json:"dateTo"`
Expand All @@ -121,7 +121,7 @@ type MeasurementSeriesGroup struct {

// MeasurementSeriesAggregateGroup represents a group of aggregate series
type MeasurementSeriesAggregateGroup struct {
Series []MeasurementSerieDefinition `json:"series"`
Series []MeasurementSeriesDefinition `json:"series"`
Values []MeasurementSeriesAggregateValueGroup `json:"values"`
DateFrom time.Time `json:"dateFrom"`
DateTo time.Time `json:"dateTo"`
Expand Down Expand Up @@ -150,12 +150,12 @@ func (d *MeasurementSeriesGroup) UnmarshalJSON(data []byte) error {
c8ySeries := gjson.ParseBytes(data)

// Get the series definitions
var seriesDefinitions []MeasurementSerieDefinition
var seriesDefinitions []MeasurementSeriesDefinition

c8ySeries.Get("series").ForEach(func(_, serie gjson.Result) bool {
v := &MeasurementSerieDefinition{}
if err := json.Unmarshal([]byte(serie.String()), &v); err != nil {
Logger.Infof("Could not unmarshal series definition. %s", serie.String())
c8ySeries.Get("series").ForEach(func(_, item gjson.Result) bool {
v := &MeasurementSeriesDefinition{}
if err := json.Unmarshal([]byte(item.String()), &v); err != nil {
Logger.Infof("Could not unmarshal series definition. %s", item.String())
}

seriesDefinitions = append(seriesDefinitions, *v)
Expand Down Expand Up @@ -211,12 +211,12 @@ func (d *MeasurementSeriesAggregateGroup) UnmarshalJSON(data []byte) error {
c8ySeries := gjson.ParseBytes(data)

// Get the series definitions
var seriesDefinitions []MeasurementSerieDefinition
var seriesDefinitions []MeasurementSeriesDefinition

c8ySeries.Get("series").ForEach(func(_, serie gjson.Result) bool {
v := &MeasurementSerieDefinition{}
if err := json.Unmarshal([]byte(serie.String()), &v); err != nil {
Logger.Infof("Could not unmarshal series definition. %s", serie.String())
c8ySeries.Get("series").ForEach(func(_, item gjson.Result) bool {
v := &MeasurementSeriesDefinition{}
if err := json.Unmarshal([]byte(item.String()), &v); err != nil {
Logger.Infof("Could not unmarshal series definition. %s", item.String())
}

seriesDefinitions = append(seriesDefinitions, *v)
Expand Down

0 comments on commit 07ecd4e

Please sign in to comment.