Skip to content

Commit

Permalink
Doing some updates to the magpie (radius-project#6925)
Browse files Browse the repository at this point in the history
# Description

**_Opened this PR not from the fork because there are some actions that
I would like to test and can't be triggered from a fork._**

1. Updating some packages
2. Changing the way we append string to an array
3. Adding missing context

## Type of change
- This pull request is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
(issue link optional).
Fixes: radius-project#6932 

## Auto-generated summary
<!--
copilot:all
-->
### <samp>🤖[[deprecated]](https://githubnext.com/copilot-for-prs-sunset)
Generated by Copilot at db8fccb</samp>

### Summary
🐰📦🚀

<!--
1. 🐰 - This emoji represents RabbitMQ, the message broker that magpiego
uses for servicebus operations. It also conveys the idea of speed and
efficiency, which are improved by using context and simplifying message
body conversion.
2. 📦 - This emoji represents the dependencies that were updated in
`go.mod`. It suggests the idea of packaging, updating, and delivering
software components. It also implies that the changes may affect the
compatibility and functionality of the magpiego bindings for different
services.
3. 🚀 - This emoji represents the overall performance and reliability
improvements that the changes may bring to magpiego. It conveys the idea
of launching, accelerating, and scaling up the application. It also
implies that the changes may enable new features and capabilities for
the users.
-->
Updated the magpiego bindings for RabbitMQ and servicebus to use context
and improve performance and readability. Also upgraded some dependencies
in `go.mod` to use the latest versions.

> _Oh we're the magpiego crew and we know what to do_
> _We import the context and we update the `go.mod`_
> _We heave away and haul away with RabbitMQ_
> _And we make the servicebus go faster and smoother too_

### Walkthrough
* Import context package and use context.Background() to create a
context for RabbitMQ operations
([link](https://github.com/radius-project/radius/pull/6925/files?diff=unified&w=0#diff-7842d685b892c11c5740e574ffc57e49b46f65fec0bfa5180c931822b19f26edR4),
[link](https://github.com/radius-project/radius/pull/6925/files?diff=unified&w=0#diff-7842d685b892c11c5740e574ffc57e49b46f65fec0bfa5180c931822b19f26edR53))
* Simplify message body conversion to string in GetMessage function for
RabbitMQ binding
([link](https://github.com/radius-project/radius/pull/6925/files?diff=unified&w=0#diff-186427a868cc7f255398e6a829f74396e4ed3f1c16dbe593cfa9e1c313fe3a45L116-R115))
* Remove unused fmt package from servicebus.go file
([link](https://github.com/radius-project/radius/pull/6925/files?diff=unified&w=0#diff-186427a868cc7f255398e6a829f74396e4ed3f1c16dbe593cfa9e1c313fe3a45L5))
* Update go.mod file to use latest versions of mongo-driver, compress,
crypto, and text packages
([link](https://github.com/radius-project/radius/pull/6925/files?diff=unified&w=0#diff-069ce70246ee93b05a3149affbf0f507f1a4482e8086c6ebb7dbeafb7df3f77dL17-R17),
[link](https://github.com/radius-project/radius/pull/6925/files?diff=unified&w=0#diff-069ce70246ee93b05a3149affbf0f507f1a4482e8086c6ebb7dbeafb7df3f77dL33-R35),
[link](https://github.com/radius-project/radius/pull/6925/files?diff=unified&w=0#diff-069ce70246ee93b05a3149affbf0f507f1a4482e8086c6ebb7dbeafb7df3f77dL41-R45))

---------

Signed-off-by: ytimocin <[email protected]>
  • Loading branch information
ytimocin authored Dec 7, 2023
1 parent 1de017a commit fb0fe3c
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 75 deletions.
13 changes: 0 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ github.com/charmbracelet/bubbletea v0.24.2 h1:uaQIKx9Ai6Gdh5zpTbGiWpytMU+CfsPp06
github.com/charmbracelet/bubbletea v0.24.2/go.mod h1:XdrNrV4J8GiyshTtx3DNuYkR1FDaJmO3l2nejekbsgg=
github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E=
github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c=
github.com/charmbracelet/x/exp/teatest v0.0.0-20230707174939-50fb4f48b5b3 h1:q2wdR6dJP78b4v7lmHRfk/f+qqdXOaw4yCIChdN8ln0=
github.com/charmbracelet/x/exp/teatest v0.0.0-20230707174939-50fb4f48b5b3/go.mod h1:TckAxPtan3aJ5wbTgBkySpc50SZhXJRZ8PtYICnZJEw=
github.com/charmbracelet/x/exp/teatest v0.0.0-20231116172829-450eedbca1ab h1:+NUNHTfqUFw9qGNU4ApqomkRl76KHhCCRmLeW/1ULaU=
github.com/charmbracelet/x/exp/teatest v0.0.0-20231116172829-450eedbca1ab/go.mod h1:TckAxPtan3aJ5wbTgBkySpc50SZhXJRZ8PtYICnZJEw=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
Expand Down Expand Up @@ -722,8 +720,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
Expand Down Expand Up @@ -949,7 +945,6 @@ github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0=
github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0=
Expand Down Expand Up @@ -1251,8 +1246,6 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -1329,17 +1322,13 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c=
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o=
golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8=
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1355,8 +1344,6 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
4 changes: 1 addition & 3 deletions test/magpiego/bindings/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
"go.mongodb.org/mongo-driver/mongo/options"
)

// FROM https://www.digitalocean.com/community/tutorials/how-to-use-go-with-mongodb-using-the-mongodb-go-driver
var ctx = context.TODO()

// MongoBinding checks if the CONNECTIONSTRING environment parameter is present and if so, attempts to connect to a MongoDB
//
// instance using the provided URI, returning a BindingStatus indicating success or failure.
Expand All @@ -21,6 +18,7 @@ func MongoBinding(envParams map[string]string) BindingStatus {
return BindingStatus{false, "CONNECTIONSTRING is required"}
}
clientOptions := options.Client().ApplyURI(uri)
ctx := context.Background()
client, err := mongo.Connect(ctx, clientOptions)
if err != nil {
log.Println("mongodb connection failed", err.Error())
Expand Down
2 changes: 2 additions & 0 deletions test/magpiego/bindings/rabbitmq.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bindings

import (
"context"
"log"

amqp "github.com/rabbitmq/amqp091-go"
Expand Down Expand Up @@ -49,6 +50,7 @@ func RabbitMQBinding(envParams map[string]string) BindingStatus {
return BindingStatus{false, "Failed to declare a queue"}
}
msg := "Hello World!"
ctx := context.Background()
err = ch.PublishWithContext(
ctx,
"", // exchange
Expand Down
3 changes: 1 addition & 2 deletions test/magpiego/bindings/servicebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package bindings

import (
"context"
"fmt"
"log"
"time"

Expand Down Expand Up @@ -113,7 +112,7 @@ func GetMessage(ctx context.Context, count int, queueName string, client *azserv
body := message.Body
log.Printf("%s\n", string(body))

result = append(result, fmt.Sprintf("%s", body))
result = append(result, string(body)) // Store the message body in the result slice

err = receiver.CompleteMessage(ctx, message, nil)
if err != nil {
Expand Down
38 changes: 19 additions & 19 deletions test/magpiego/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@ module github.com/radius-project/radius/test/magpiego
go 1.20

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.2
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets v0.12.0
github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus v1.4.1
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0
github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus v1.5.0
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0
github.com/dapr/go-sdk v1.9.1
github.com/denisenkom/go-mssqldb v0.12.3
github.com/go-chi/chi/v5 v5.0.10
github.com/go-redis/redis/v8 v8.11.5
github.com/rabbitmq/amqp091-go v1.8.1
go.mongodb.org/mongo-driver v1.12.1
github.com/rabbitmq/amqp091-go v1.9.0
go.mongodb.org/mongo-driver v1.13.1
)

require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal v0.7.1 // indirect
github.com/Azure/go-amqp v1.0.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dapr/dapr v1.12.0-rc.4 // indirect
github.com/dapr/dapr v1.12.2 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/montanaflynn/stats v0.7.0 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
google.golang.org/grpc v1.57.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit fb0fe3c

Please sign in to comment.