From 0c8b735c1bd0aa2b0505fc6cb3b153c7388784fb Mon Sep 17 00:00:00 2001 From: Matt Fontenot Date: Wed, 8 Mar 2023 14:56:21 -0600 Subject: [PATCH 1/7] added-kds-pub --- .DS_Store | Bin 0 -> 6148 bytes chans/kdspub/kds_test.go | 25 +++++++ chans/kdspub/kdspub.go | 148 +++++++++++++++++++++++++++++++++++++++ chans/std/std.go | 1 + go.mod | 3 + go.sum | 29 ++++++++ 6 files changed, 206 insertions(+) create mode 100644 .DS_Store create mode 100644 chans/kdspub/kds_test.go create mode 100644 chans/kdspub/kdspub.go diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..328712d4715d4b341186735a4e32a5357e67129e GIT binary patch literal 6148 zcmeH~I|>3p42BaQAlO)1PU8W*!654iynwI5LbMS3Il6xy2(H#5@&}TCCX*=p6+0Ud z(bfI96q$+01a2w|3q4cp$8wO9?BpW1aPw29|52vq}{OgSpr%t0j;Sm6d9OCD>Pcw z#}LbVJG5k7O>LpkE}FxK=0B@VF))pG(Si+3s|y1OkU)>XF!nRM|JU$O^M9{}TM{6F zKO>-{Zqu#sP Date: Tue, 14 Mar 2023 09:59:36 -0500 Subject: [PATCH 2/7] 2023 --- chans/kdspub/kdspub.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chans/kdspub/kdspub.go b/chans/kdspub/kdspub.go index 8033277..2e224c9 100644 --- a/chans/kdspub/kdspub.go +++ b/chans/kdspub/kdspub.go @@ -1,5 +1,5 @@ /* - * Copyright 2021 Comcast Cable Communications Management, LLC + * Copyright 2023 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import ( "fmt" "github.com/Comcast/plax/dsl" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/kinesis" From e892b0002398794c55cdfaf4ca826d34ad344092 Mon Sep 17 00:00:00 2001 From: Matt Fontenot Date: Tue, 14 Mar 2023 09:59:41 -0500 Subject: [PATCH 3/7] 2023 --- chans/kdspub/kds_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chans/kdspub/kds_test.go b/chans/kdspub/kds_test.go index 2d222b5..fd08dc3 100644 --- a/chans/kdspub/kds_test.go +++ b/chans/kdspub/kds_test.go @@ -1,5 +1,5 @@ /* - * Copyright 2021 Comcast Cable Communications Management, LLC + * Copyright 2023 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 7c26f45474bd53b208aa1f1e226a72eddd79df52 Mon Sep 17 00:00:00 2001 From: Matt Fontenot Date: Tue, 14 Mar 2023 10:31:03 -0500 Subject: [PATCH 4/7] test --- chans/kdspub/kdspub.go | 1 + 1 file changed, 1 insertion(+) diff --git a/chans/kdspub/kdspub.go b/chans/kdspub/kdspub.go index 2e224c9..893b80f 100644 --- a/chans/kdspub/kdspub.go +++ b/chans/kdspub/kdspub.go @@ -51,6 +51,7 @@ type KDSOpts struct { type KDSPubChan struct { c chan dsl.Msg ctl chan bool + svc *kinesis.PutRecordInput opts *KDSOpts } From f4adae1fec869dad55e1be7d3b9a1614bdfa858f Mon Sep 17 00:00:00 2001 From: Matt Fontenot Date: Tue, 14 Mar 2023 13:05:18 -0500 Subject: [PATCH 5/7] PR comments changes --- chans/kdspub/kdspub.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/chans/kdspub/kdspub.go b/chans/kdspub/kdspub.go index 893b80f..86a1d6c 100644 --- a/chans/kdspub/kdspub.go +++ b/chans/kdspub/kdspub.go @@ -51,7 +51,7 @@ type KDSOpts struct { type KDSPubChan struct { c chan dsl.Msg ctl chan bool - svc *kinesis.PutRecordInput + svc *kinesis.Client opts *KDSOpts } @@ -90,10 +90,14 @@ func (c *KDSPubChan) Kind() dsl.ChanKind { func (c *KDSPubChan) Open(ctx *dsl.Ctx) error { - // Not doing anything here for the monment. Might eventually - // want to do establish the session and KDS client here for - // efficient in case the test wants to publish several - // messages. + cfg, err := config.LoadDefaultConfig(context.TODO()) + if err != nil { + ctx.Logf("Error opening KDS stream %s", c.opts.StreamName) + } + + c.svc = kinesis.NewFromConfig(cfg) + + go c.Pub(ctx, dsl.Msg{}) return nil } @@ -110,13 +114,6 @@ func (c *KDSPubChan) Pub(ctx *dsl.Ctx, m dsl.Msg) error { ctx.Logf("Publishing to KDS %s", c.opts.StreamName) // Load the Shared AWS Configuration (~/.aws/config) - cfg, err := config.LoadDefaultConfig(context.TODO()) - if err != nil { - ctx.Logf("Error publishing to KDS %s", c.opts.StreamName) - - } - - k := kinesis.NewFromConfig(cfg) input := &kinesis.PutRecordInput{ Data: []byte(m.Payload), @@ -124,9 +121,9 @@ func (c *KDSPubChan) Pub(ctx *dsl.Ctx, m dsl.Msg) error { PartitionKey: aws.String("test"), } - _, err2 := k.PutRecord(context.TODO(), input) + _, err := c.svc.PutRecord(context.TODO(), input) - if err2 != nil { + if err != nil { ctx.Warnf("warning: KDSPubChan.PUB %s", err) } return nil From abfc593bc61dff5420d2be13d143ede8fd9f9831 Mon Sep 17 00:00:00 2001 From: Matt Fontenot Date: Tue, 14 Mar 2023 13:06:00 -0500 Subject: [PATCH 6/7] Copy write year change --- chans/std/std.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chans/std/std.go b/chans/std/std.go index a037c2f..9285a5f 100644 --- a/chans/std/std.go +++ b/chans/std/std.go @@ -1,5 +1,5 @@ /* - * Copyright 2021 Comcast Cable Communications Management, LLC + * Copyright 2023 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 17599a815231b63c5b1a293ddc3793e721af77dd Mon Sep 17 00:00:00 2001 From: Matt Fontenot Date: Tue, 14 Mar 2023 13:12:15 -0500 Subject: [PATCH 7/7] remove .DS_Store --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cbcc4f7..237def2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dist/ vendor/ *~ **/__debug_bin +.DS_Store \ No newline at end of file