From 3a5f8d8824aa77647a58c72a4e755d6015427508 Mon Sep 17 00:00:00 2001 From: Gildas Cherruel Date: Fri, 21 Jun 2024 19:25:03 +0900 Subject: [PATCH 1/4] The client should honor the Retry-After header --- request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/request.go b/request.go index 01e3b59..fff9b7a 100644 --- a/request.go +++ b/request.go @@ -79,6 +79,7 @@ func (client *Client) SendRequest(context context.Context, uri URI, options *req options.Logger = log options.ResponseBodyLogSize = 4096 options.Timeout = client.RequestTimeout + options.InterAttemptUseRetryAfter = true log.Record("payload", options.Payload).Debugf("Sending request to %s", options.URL) start := time.Now() From 5a236c6b363909f847eaa709c0031d6b51c20340 Mon Sep 17 00:00:00 2001 From: Gildas Cherruel Date: Fri, 21 Jun 2024 19:25:58 +0900 Subject: [PATCH 2/4] the Open Messaging Integration shold use the logger from the context by default --- openmessaging_integration.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/openmessaging_integration.go b/openmessaging_integration.go index 51efb77..2553879 100644 --- a/openmessaging_integration.go +++ b/openmessaging_integration.go @@ -119,8 +119,9 @@ func (integration *OpenMessagingIntegration) Delete(context context.Context) err if integration.ID == uuid.Nil { return nil } + log := logger.Must(logger.FromContext(context, integration.logger)).Child("integration", "getmessagedata", "integration", integration.ID) return integration.Client.Delete( - integration.logger.ToContext(context), + log.ToContext(context), NewURI("/conversations/messaging/integrations/open/%s", integration.ID), nil, ) @@ -184,7 +185,8 @@ func (integration *OpenMessagingIntegration) GetRoutingMessageRecipient(context if !integration.IsCreated() { return nil, errors.CreationFailed.With("integration", integration.ID) } - return Fetch[RoutingMessageRecipient](context, integration.Client, integration) + log := logger.Must(logger.FromContext(context, integration.logger)).Child("integration", "getmessagedata", "integration", integration.ID) + return Fetch[RoutingMessageRecipient](log.ToContext(context), integration.Client, integration) } // SendInboundTextMessage sends an Open Message text message from the middleware to GENESYS Cloud @@ -210,12 +212,13 @@ func (integration *OpenMessagingIntegration) SendInboundTextMessage(context cont if len(message.Text) == 0 { return "", errors.ArgumentMissing.With("text") } + log := logger.Must(logger.FromContext(context, integration.logger)).Child("integration", "getmessagedata", "integration", integration.ID, "message", message.GetID()) message.Direction = "Inbound" // TODO: attributes and metadata should be of a new type Metadata that containd a map and a []string for keysToRedact result := OpenMessageText{} err = integration.Client.Post( - integration.logger.ToContext(context), + log.ToContext(context), NewURI("/conversations/messages/%s/inbound/open/message", integration.ID), message, &result, @@ -254,9 +257,10 @@ func (integration *OpenMessagingIntegration) SendInboundReceipt(context context. return "", err } + log := logger.Must(logger.FromContext(context, integration.logger)).Child("integration", "getmessagedata", "integration", integration.ID, "receipt", receipt.GetID()) result := OpenMessageReceipt{} err = integration.Client.Post( - integration.logger.ToContext(context), + log.ToContext(context), NewURI("/conversations/messages/%s/inbound/open/receipt", integration.ID), receipt, &result, @@ -286,8 +290,9 @@ func (integration *OpenMessagingIntegration) SendInboundEvents(context context.C return "", err } result := OpenMessageEvents{} + log := logger.Must(logger.FromContext(context, integration.logger)).Child("integration", "getmessagedata", "integration", integration.ID, "message", events.GetID()) err = integration.Client.Post( - integration.logger.ToContext(context), + log.ToContext(context), NewURI("/conversations/messages/%s/inbound/open/event", integration.ID), events, &result, @@ -306,9 +311,10 @@ func (integration *OpenMessagingIntegration) SendOutboundMessage(context context if integration.ID == uuid.Nil { return nil, errors.ArgumentMissing.With("ID") } + log := logger.Must(logger.FromContext(context, integration.logger)).Child("integration", "getmessagedata", "integration", integration.ID) result := &AgentlessMessageResult{} err := integration.Client.Post( - integration.logger.ToContext(context), + log.ToContext(context), "/conversations/messages/agentless", AgentlessMessage{ From: integration.ID.String(), @@ -332,9 +338,10 @@ func (integration *OpenMessagingIntegration) GetMessageData(context context.Cont if len(message.GetID()) == 0 { return nil, errors.ArgumentMissing.With("messageID") } + log := logger.Must(logger.FromContext(context, integration.logger)).Child("integration", "getmessagedata", "integration", integration.ID, "message", message.GetID()) data := &OpenMessageData{} err := integration.Client.Get( - integration.logger.ToContext(context), + log.ToContext(context), NewURI("/conversations/messages/%s/details", message.GetID()), data, ) From dcf73edd4e1ea977ea3115038db20867c396be16 Mon Sep 17 00:00:00 2001 From: Gildas Cherruel Date: Fri, 21 Jun 2024 19:54:45 +0900 Subject: [PATCH 3/4] Updated modules --- go.mod | 16 ++++++++-------- go.sum | 32 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index 27ed098..2e07595 100644 --- a/go.mod +++ b/go.mod @@ -8,12 +8,12 @@ require ( github.com/Masterminds/sprig/v3 v3.2.3 github.com/gildas/go-core v0.5.8 github.com/gildas/go-errors v0.3.6 - github.com/gildas/go-logger v1.7.1 - github.com/gildas/go-request v0.9.5 + github.com/gildas/go-logger v1.7.2 + github.com/gildas/go-request v0.9.6 github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.1 github.com/gorilla/securecookie v1.1.2 - github.com/gorilla/websocket v1.5.2 + github.com/gorilla/websocket v1.5.3 github.com/joho/godotenv v1.5.1 github.com/matoous/go-nanoid/v2 v2.1.0 github.com/stretchr/testify v1.9.0 @@ -36,7 +36,7 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.4 // indirect + github.com/googleapis/gax-go/v2 v2.12.5 // indirect github.com/huandu/xstrings v1.5.0 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect @@ -57,10 +57,10 @@ require ( golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect - google.golang.org/api v0.184.0 // indirect - google.golang.org/genproto v0.0.0-20240610135401-a8a62080eff3 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240610135401-a8a62080eff3 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 // indirect + google.golang.org/api v0.185.0 // indirect + google.golang.org/genproto v0.0.0-20240617180043-68d350f18fd4 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect google.golang.org/grpc v1.64.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 290203f..695eaaf 100644 --- a/go.sum +++ b/go.sum @@ -39,10 +39,10 @@ github.com/gildas/go-core v0.5.8 h1:4j192jB6BqXlnjjw1/EVvm6qXqV4f9ZuI3E6s68ZNb0= github.com/gildas/go-core v0.5.8/go.mod h1:086mC22MxbhI8bm3cm+w6DBnNwY7+TYkfMe4lUGj8vc= github.com/gildas/go-errors v0.3.6 h1:/loKTkq/t+eoIcULhKAwd0WBRPHgZxhkd3l+m/uw15c= github.com/gildas/go-errors v0.3.6/go.mod h1:jqH4hy2BzpU3mdjkUYJhkZvEkn56cWRjWVgz/HNqglQ= -github.com/gildas/go-logger v1.7.1 h1:6gbN5QPLP1vntpbV6cTSObaNwdrjndl1GfLJcbZ8eYw= -github.com/gildas/go-logger v1.7.1/go.mod h1:N2LqqOvcYJsCoGq5GAygIzWJWTr8sIUq072sdXNnyws= -github.com/gildas/go-request v0.9.5 h1:XAV19mXCdZ84UBx4ZU6fu2vL6ocWDEqDMqENz4nlcEY= -github.com/gildas/go-request v0.9.5/go.mod h1:IayVqAs/QDsvXy2HrCN0aiMSknFQFsAcyViwa2itmDs= +github.com/gildas/go-logger v1.7.2 h1:HfESDm0OmJ/JDgZijuHtv3sDqCMWpgUCedEd7jgVmYk= +github.com/gildas/go-logger v1.7.2/go.mod h1:jO6QrO8hnxkLhVjWiEIOH5OeSb7Nrr55SW8qKAEgUUE= +github.com/gildas/go-request v0.9.6 h1:71T3QTC0yE+lG3GCQmDjNT+/fHwtqAxobOCj1vu5ypg= +github.com/gildas/go-request v0.9.6/go.mod h1:kJJTYDTMQbImsGPF5zETpDMqTqMs5DziRkoJLrBjerI= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -82,14 +82,14 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs= github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= -github.com/googleapis/gax-go/v2 v2.12.4 h1:9gWcmF85Wvq4ryPFvGFaOgPIs1AQX0d0bcbGw4Z96qg= -github.com/googleapis/gax-go/v2 v2.12.4/go.mod h1:KYEYLorsnIGDi/rPC8b5TdlB9kbKoFubselGIoBMCwI= +github.com/googleapis/gax-go/v2 v2.12.5 h1:8gw9KZK8TiVKB6q3zHY3SBzLnrGp6HQjyfYBYGmXdxA= +github.com/googleapis/gax-go/v2 v2.12.5/go.mod h1:BUDKcWo+RaKq5SC9vVYL0wLADa3VcfswbOMMRmB9H3E= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= -github.com/gorilla/websocket v1.5.2 h1:qoW6V1GT3aZxybsbC6oLnailWnB+qTMVwMreOso9XUw= -github.com/gorilla/websocket v1.5.2/go.mod h1:0n9H61RBAcf5/38py2MCYbxzPIY9rOkpvvMT24Rqs30= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= @@ -209,19 +209,19 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.184.0 h1:dmEdk6ZkJNXy1JcDhn/ou0ZUq7n9zropG2/tR4z+RDg= -google.golang.org/api v0.184.0/go.mod h1:CeDTtUEiYENAf8PPG5VZW2yNp2VM3VWbCeTioAZBTBA= +google.golang.org/api v0.185.0 h1:ENEKk1k4jW8SmmaT6RE+ZasxmxezCrD5Vw4npvr+pAU= +google.golang.org/api v0.185.0/go.mod h1:HNfvIkJGlgrIlrbYkAm9W9IdkmKZjOTVh33YltygGbg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20240610135401-a8a62080eff3 h1:8RTI1cmuvdY9J7q/jpJWEj5UfgWjhV5MCoXaYmwLBYQ= -google.golang.org/genproto v0.0.0-20240610135401-a8a62080eff3/go.mod h1:qb66gsewNb7Ghv1enkhJiRfYGWUklv3n6G8UvprOhzA= -google.golang.org/genproto/googleapis/api v0.0.0-20240610135401-a8a62080eff3 h1:QW9+G6Fir4VcRXVH8x3LilNAb6cxBGLa6+GM4hRwexE= -google.golang.org/genproto/googleapis/api v0.0.0-20240610135401-a8a62080eff3/go.mod h1:kdrSS/OiLkPrNUpzD4aHgCq2rVuC/YRxok32HXZ4vRE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 h1:9Xyg6I9IWQZhRVfCWjKK+l6kI0jHcPesVlMnT//aHNo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/genproto v0.0.0-20240617180043-68d350f18fd4 h1:CUiCqkPw1nNrNQzCCG4WA65m0nAmQiwXHpub3dNyruU= +google.golang.org/genproto v0.0.0-20240617180043-68d350f18fd4/go.mod h1:EvuUDCulqGgV80RvP1BHuom+smhX4qtlhnNatHuroGQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 h1:MuYw1wJzT+ZkybKfaOXKp5hJiZDn2iHaXRw0mRYdHSc= +google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4/go.mod h1:px9SlOOZBg1wM1zdnr8jEL4CNGUBZ+ZKYtNPApNQc4c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 h1:Di6ANFilr+S60a4S61ZM00vLdw0IrQOSMS2/6mrnOU0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= From 1648055e030d93f0ad6d4a45f1c2f612df9ba273 Mon Sep 17 00:00:00 2001 From: Gildas Cherruel Date: Fri, 21 Jun 2024 19:54:54 +0900 Subject: [PATCH 4/4] Bumped to version 0.9.2 --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index 05cbb07..ab44bb6 100644 --- a/version.go +++ b/version.go @@ -4,7 +4,7 @@ package gcloudcx var commit string // VERSION is the version of this application -var VERSION = "0.9.1" + commit +var VERSION = "0.9.2" + commit // APP is the name of the application const APP string = "GCloudCX Client"