@@ -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
2221type 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.
0 commit comments