@@ -12,12 +12,14 @@ import (
12
12
"regexp"
13
13
"runtime"
14
14
"strings"
15
+ "time"
15
16
16
17
"github.com/google/uuid"
17
18
"google.golang.org/grpc"
18
19
"google.golang.org/grpc/credentials"
19
20
"google.golang.org/grpc/credentials/insecure"
20
21
"google.golang.org/grpc/metadata"
22
+ "google.golang.org/protobuf/types/known/timestamppb"
21
23
22
24
"github.com/netboxlabs/diode-sdk-go/diode/v1/diodepb"
23
25
)
@@ -230,10 +232,7 @@ func (g *GRPCClient) Close() error {
230
232
func (g * GRPCClient ) Ingest (ctx context.Context , entities []Entity ) (* diodepb.IngestResponse , error ) {
231
233
stream := defaultStreamName
232
234
233
- protoEntities := make ([]* diodepb.Entity , 0 )
234
- for _ , entity := range entities {
235
- protoEntities = append (protoEntities , entity .ConvertToProtoEntity ())
236
- }
235
+ protoEntities := convertEntitiesToProto (entities )
237
236
238
237
req := & diodepb.IngestRequest {
239
238
Id : uuid .NewString (),
@@ -250,6 +249,17 @@ func (g *GRPCClient) Ingest(ctx context.Context, entities []Entity) (*diodepb.In
250
249
return g .client .Ingest (ctx , req )
251
250
}
252
251
252
+ // convertEntitiesToProto converts entities to proto entities
253
+ func convertEntitiesToProto (entities []Entity ) []* diodepb.Entity {
254
+ protoEntities := make ([]* diodepb.Entity , 0 )
255
+ for _ , entity := range entities {
256
+ entityPb := entity .ConvertToProtoEntity ()
257
+ entityPb .Timestamp = timestamppb .New (time .Now ().UTC ())
258
+ protoEntities = append (protoEntities , entityPb )
259
+ }
260
+ return protoEntities
261
+ }
262
+
253
263
// methodUnaryInterceptor returns a gRPC dial option with a unary interceptor
254
264
//
255
265
// It's used to intercept the client calls and modify the method details.
0 commit comments