Skip to content

Commit e08021b

Browse files
Danielius1922Daniel Adam
authored andcommitted
grpc-gateway: remove unused functions
1 parent 64b6707 commit e08021b

4 files changed

Lines changed: 0 additions & 72 deletions

File tree

grpc-gateway/client/client.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
kitNetGrpc "github.com/plgd-dev/hub/pkg/net/grpc"
1717
"github.com/plgd-dev/hub/resource-aggregate/commands"
1818
"github.com/plgd-dev/hub/resource-aggregate/events"
19-
"github.com/plgd-dev/kit/v2/strings"
2019
)
2120

2221
type ApplicationCallback interface {
@@ -156,46 +155,6 @@ func (c *Client) GetResourceLinksViaCallback(ctx context.Context, deviceIDs, res
156155
return it.Err
157156
}
158157

159-
type TypeCallback struct {
160-
Type string
161-
Callback func(*pb.Resource)
162-
}
163-
164-
func MakeTypeCallback(resourceType string, callback func(*pb.Resource)) TypeCallback {
165-
return TypeCallback{Type: resourceType, Callback: callback}
166-
}
167-
168-
// GetResourcesByType gets contents of resources by resource types. JWT token must be stored in context for grpc call.
169-
func (c *Client) GetResourcesByType(
170-
ctx context.Context,
171-
deviceIDs []string,
172-
typeCallbacks ...TypeCallback,
173-
) error {
174-
tc := make(map[string]func(*pb.Resource), len(typeCallbacks))
175-
resourceTypes := make([]string, 0, len(typeCallbacks))
176-
for _, c := range typeCallbacks {
177-
tc[c.Type] = c.Callback
178-
resourceTypes = append(resourceTypes, c.Type)
179-
}
180-
181-
it := c.GetResourcesIterator(ctx, nil, deviceIDs, resourceTypes...)
182-
defer it.Close()
183-
184-
for {
185-
var v pb.Resource
186-
if !it.Next(&v) {
187-
break
188-
}
189-
for _, rt := range resourceTypes {
190-
if strings.SliceContains(v.Types, rt) {
191-
tc[rt](&v)
192-
break
193-
}
194-
}
195-
}
196-
return it.Err
197-
}
198-
199158
// GetDevicesIterator gets devices. JWT token must be stored in context for grpc call.
200159
// Next queries the next resource value.
201160
// Returns false when failed or having no more items.

grpc-gateway/client/deviceSubscription.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,3 @@ func (s *DeviceSubscription) Cancel() (wait func(), err error) {
4949
func (s *DeviceSubscription) ID() string {
5050
return s.id
5151
}
52-
53-
func ToDeviceSubscription(v interface{}, ok bool) (*DeviceSubscription, bool) {
54-
if !ok {
55-
return nil, false
56-
}
57-
if v == nil {
58-
return nil, false
59-
}
60-
s, ok := v.(*DeviceSubscription)
61-
return s, ok
62-
}

grpc-gateway/client/deviceSubscriptions.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,3 @@ func (s *DeviceSubscriptions) runRecv() {
548548
s.handleEvent(ev)
549549
}
550550
}
551-
552-
func ToDeviceSubscriptions(v interface{}, ok bool) (*DeviceSubscriptions, bool) {
553-
if !ok {
554-
return nil, false
555-
}
556-
if v == nil {
557-
return nil, false
558-
}
559-
s, ok := v.(*DeviceSubscriptions)
560-
return s, ok
561-
}

grpc-gateway/client/observeDeviceResources.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,3 @@ func (c *Client) stopObservingDeviceResources(observationID string) (wait func()
6565
}
6666
return s.Cancel()
6767
}
68-
69-
func (c *Client) StopObservingDeviceResources(ctx context.Context, observationID string) error {
70-
wait, err := c.stopObservingDeviceResources(observationID)
71-
if err != nil {
72-
return err
73-
}
74-
wait()
75-
return nil
76-
}

0 commit comments

Comments
 (0)