Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vmware-archive/transport-go
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.3.2
Choose a base ref
...
head repository: vmware-archive/transport-go
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 12 commits
  • 67 files changed
  • 2 contributors

Commits on Nov 2, 2021

  1. new: Add SendBroadcastMessage() bus method (#41)

    This PR implements a new method to the event bus API that will
    hopefully reduce confusion around use of the basic event bus API
    methods around broadcasting scenarios. Details can be tracked in this
    GitHub issue: #40
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Nov 2, 2021
    Copy the full SHA
    4cd6850 View commit details

Commits on Dec 1, 2021

  1. new: Add method to Message to cast to a given type (#43)

    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Dec 1, 2021
    Copy the full SHA
    27e75b6 View commit details
  2. [fix] Add missing STOMP over TCP option for Plank (#42)

    * [fix] Add missing STOMP over TCP option for Plank
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    
    * [fix] incorrect outbound send call for incoming msg
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    
    * (new) broker_sample example talking to another Plank via TCP
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    
    * fix: handle server start errors properly
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    
    * test: increase test coverage
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    
    * change: simplify sample code using CastPayloadToType
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Dec 1, 2021
    Copy the full SHA
    553eea5 View commit details

Commits on Dec 2, 2021

  1. change: use better StockTickerService API provider (#28)

    * change: use better StockTickerService API provider
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    
    * Include closePrice in return data structure
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Dec 2, 2021
    Copy the full SHA
    3c1a8f0 View commit details

Commits on Dec 8, 2021

  1. Fix UUID equality check bug (#45)

    * format: gofmt on all source files
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    
    * fix: UUID comparison logic bug
    
    UUID is used throughout the entire codebase of Transport and is
    especially important in filtering messages based on their destination.
    While implementing basic WASM bridge for the bus I realized that UUID
    comparison was failing, i.e. returning true for the equality check
    between two dififerent UUID instances. Turns out the use of .ID()
    method on the UUID object only returns the first 4 bytes of the
    underlying 16-byte slice. This means as long as the first 8
    hexadecimal characters matched between two UUID instances, they would
    come out as equal, and it would therefore mean a significantly higher
    chance of UUID collision.. The fix introduced in this PR is to use
    the string comparison of the full UUID in places where .ID() was used.
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Dec 8, 2021
    Copy the full SHA
    6d9ecb6 View commit details

Commits on Feb 17, 2022

  1. Disable boot image by default (#48)

    Consuming ~700kB just for the purpose of showing a splash image is not
    a good idea for a library, hence disabling it by default and making it
    an opt-in feature. Use `--tags boot_img` in `go build` or `go run`
    to opt in.
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Feb 17, 2022
    Copy the full SHA
    979915f View commit details
  2. test: More server pkg unit tests (#44)

    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Feb 17, 2022
    Copy the full SHA
    77c3333 View commit details

Commits on Feb 20, 2022

  1. Fix current map write bug in rest bridge config (#49)

    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Feb 20, 2022
    Copy the full SHA
    5ca9bcc View commit details

Commits on Mar 2, 2022

  1. Improve response payload casting operation (#50)

    `model.Message` struct has a method `CastPayloadToType` used to
    conveniently cast `Message.Payload.(Response).Payload` into the type of
    the provided argument. The current implementation had a few gaps that
    made the method only viaible in situations where `Message.Payload`
    were yet to be unmarshalled (e.g. `interface{} | []byte`).
    
    This PR also fixes a bug in rest_service.go where `RestServiceRequest.ResponseType`
    was never customizable, leading to the response body to be always
    treated like a JSON-decodable structure. This would cause HTTP calls
    whose response type is not of JSON to throw errors. By only
    deserializing the body for which the request header `Content-Type` is
    of JSON type and passing others as raw byte slices, the RestService
    callers can handle response payloads of arbitrary MIME types.
    
    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Mar 2, 2022
    Copy the full SHA
    9ad7c33 View commit details

Commits on Feb 6, 2023

  1. Fix memory leak bug in StockTickerService Plank sample service (#53)

    Signed-off-by: Josh Kim <jsk9260@gmail.com>
    jooskim authored Feb 6, 2023
    Copy the full SHA
    51f2947 View commit details

Commits on Mar 30, 2023

  1. Fix vulnerabilities by bumping dependency versions in go.mod (#54)

    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Mar 30, 2023
    Copy the full SHA
    f5a624b View commit details
  2. Bump golang.org/x/net to fix remaining lib-induced vulnerabilities (#55)

    Signed-off-by: Josh Kim <kjosh@vmware.com>
    jooskim authored Mar 30, 2023
    Copy the full SHA
    32bcedb View commit details
Showing with 4,277 additions and 3,543 deletions.
  1. +15 −15 bridge/broker_connector_config.go
  2. +6 −5 bridge/broker_connector_test.go
  3. +67 −67 bridge/example_connector_broker_tcp_test.go
  4. +62 −62 bridge/example_connector_broker_ws_test.go
  5. +128 −128 bus/channel.go
  6. +5 −5 bus/channel_event_handler.go
  7. +195 −200 bus/channel_manager_test.go
  8. +1 −1 bus/doc.go
  9. +15 −1 bus/eventbus.go
  10. +33 −4 bus/eventbus_test.go
  11. +80 −80 bus/example_galactic_channels_test.go
  12. +322 −325 bus/fabric_endpoint_test.go
  13. +41 −41 bus/message_handler.go
  14. +13 −14 bus/message_test.go
  15. +20 −19 bus/monitor_event.go
  16. +61 −61 bus/mutation_store_stream.go
  17. +377 −377 bus/store.go
  18. +158 −159 bus/store_manager_test.go
  19. +63 −63 bus/store_stream.go
  20. +231 −232 bus/store_sync_service.go
  21. +482 −482 bus/store_sync_service_test.go
  22. +176 −174 bus/transaction.go
  23. +209 −212 bus/transaction_test.go
  24. +57 −10 go.mod
  25. +56 −9 go.sum
  26. +40 −40 log/logger.go
  27. +58 −14 model/message.go
  28. +147 −0 model/message_test.go
  29. +25 −25 model/store_responses.go
  30. +22 −22 model/util.go
  31. +16 −16 plank/README.md
  32. +4 −1 plank/cmd/broker_sample/app.go
  33. +72 −0 plank/cmd/broker_sample/plank/over_tcp.go
  34. +2 −0 plank/config.json
  35. +2 −2 plank/pkg/metrics/pageview_metric.go
  36. +4 −4 plank/pkg/middleware/cache_control.go
  37. +2 −2 plank/pkg/middleware/prometheus_metrics.go
  38. +10 −6 plank/pkg/server/banner.go
  39. +9 −0 plank/pkg/server/banner_fs.go
  40. +8 −0 plank/pkg/server/banner_fs_default.go
  41. +70 −0 plank/pkg/server/banner_test.go
  42. +36 −0 plank/pkg/server/base_error.go
  43. +47 −0 plank/pkg/server/base_error_test.go
  44. +2 −0 plank/pkg/server/core_models.go
  45. +3 −3 plank/pkg/server/endpointer_handler_factory.go
  46. +7 −9 plank/pkg/server/helpers.go
  47. +18 −0 plank/pkg/server/helpers_test.go
  48. +9 −6 plank/pkg/server/initialize.go
  49. +2 −2 plank/pkg/server/prometheus.go
  50. +33 −15 plank/pkg/server/server.go
  51. +55 −10 plank/pkg/server/server_smoke_test.go
  52. +8 −8 plank/pkg/server/spa_config.go
  53. +23 −0 plank/pkg/server/test_server.crt.go
  54. +31 −0 plank/pkg/server/test_server.key.go
  55. +29 −0 plank/pkg/server/test_suite_harness.go
  56. +66 −70 plank/services/stock-ticker-service.go
  57. +7 −7 plank/utils/console_helpers.go
  58. +4 −5 service/fabric_service.go
  59. +10 −0 service/rest_service.go
  60. +328 −334 service/rest_service_test.go
  61. +9 −9 service/service_lifecycle_manager.go
  62. +1 −2 service/service_lifecycle_manager_test.go
  63. +4 −4 service/service_registry.go
  64. +131 −131 service/service_registry_test.go
  65. +26 −31 stompserver/config.go
  66. +9 −9 stompserver/errors.go
  67. +15 −10 stompserver/server.go
30 changes: 15 additions & 15 deletions bridge/broker_connector_config.go
Original file line number Diff line number Diff line change
@@ -10,25 +10,25 @@ import (
)

type WebSocketConfig struct {
WSPath string // if UseWS is true, set this to your websocket path (e.g. '/fabric')
UseTLS bool // use TLS encryption with WebSocket connection
WSPath string // if UseWS is true, set this to your websocket path (e.g. '/fabric')
UseTLS bool // use TLS encryption with WebSocket connection
TLSConfig *tls.Config // TLS config for WebSocket connection
CertFile string // X509 certificate for TLS
KeyFile string // matching key file for the X509 certificate
CertFile string // X509 certificate for TLS
KeyFile string // matching key file for the X509 certificate
}

// BrokerConnectorConfig is a configuration used when connecting to a message broker
type BrokerConnectorConfig struct {
Username string
Password string
ServerAddr string
UseWS bool // use WebSocket instead of TCP
WebSocketConfig *WebSocketConfig // WebSocket configuration for when UseWS is true
HostHeader string
HeartBeatOut time.Duration // outbound heartbeat interval (from client to server)
HeartBeatIn time.Duration // inbound heartbeat interval (from server to client)
STOMPHeader map[string]string // additional STOMP headers for handshake
HttpHeader http.Header // additional HTTP headers for WebSocket Upgrade
Username string
Password string
ServerAddr string
UseWS bool // use WebSocket instead of TCP
WebSocketConfig *WebSocketConfig // WebSocket configuration for when UseWS is true
HostHeader string
HeartBeatOut time.Duration // outbound heartbeat interval (from client to server)
HeartBeatIn time.Duration // inbound heartbeat interval (from server to client)
STOMPHeader map[string]string // additional STOMP headers for handshake
HttpHeader http.Header // additional HTTP headers for WebSocket Upgrade
}

// LoadX509KeyPairFromFiles loads from paths to x509 cert and its matching key files and initializes
@@ -46,4 +46,4 @@ func (b *WebSocketConfig) LoadX509KeyPairFromFiles(certFile, keyFile string) err
}
}
return err
}
}
11 changes: 6 additions & 5 deletions bridge/broker_connector_test.go
Original file line number Diff line number Diff line change
@@ -7,17 +7,18 @@ import (
"bufio"
"bytes"
"fmt"
"github.com/go-stomp/stomp/v3/frame"
"github.com/go-stomp/stomp/v3/server"
"github.com/gorilla/websocket"
"github.com/stretchr/testify/assert"
"log"
"net"
"net/http"
"net/http/httptest"
"net/url"
"testing"
"time"

"github.com/go-stomp/stomp/v3/frame"
"github.com/go-stomp/stomp/v3/server"
"github.com/gorilla/websocket"
"github.com/stretchr/testify/assert"
)

var upgrader = websocket.Upgrader{}
@@ -278,7 +279,7 @@ func TestBrokerConnector_Subscribe(t *testing.T) {

// check re-subscribe returns same sub
s2, _ := c.Subscribe("/topic/test")
assert.Equal(t, s.GetId().ID(), s2.GetId().ID())
assert.Equal(t, s.GetId().String(), s2.GetId().String())

c.Disconnect()
})
134 changes: 67 additions & 67 deletions bridge/example_connector_broker_tcp_test.go
Original file line number Diff line number Diff line change
@@ -4,75 +4,75 @@
package bridge_test

import (
"fmt"
"github.com/vmware/transport-go/bridge"
"github.com/vmware/transport-go/bus"
"fmt"
"github.com/vmware/transport-go/bridge"
"github.com/vmware/transport-go/bus"
)

func Example_connectUsingBrokerViaTCP() {

// get a reference to the event bus.
b := bus.GetBus()

// create a broker connector configuration, using WebSockets.
// Make sure you have a STOMP TCP server running like RabbitMQ
config := &bridge.BrokerConnectorConfig{
Username: "guest",
Password: "guest",
ServerAddr: ":61613",
STOMPHeader: map[string]string{
"access-token": "test",
},
}

// connect to broker.
c, err := b.ConnectBroker(config)
if err != nil {
fmt.Printf("unable to connect, error: %e", err)
}
defer c.Disconnect()

// subscribe to our demo simple-stream
s, _ := c.Subscribe("/queue/sample")

// set a counter
n := 0

// create a control chan
done := make(chan bool)

// listen for messages
var consumer = func() {
for {
// listen for incoming messages from subscription.
m := <-s.GetMsgChannel()
n++

// get byte array.
d := m.Payload.([]byte)

fmt.Printf("Message Received: %s\n", string(d))
// listen for 5 messages then stop.
if n >= 5 {
break
}
}
done <- true
}

// send messages
var producer = func() {
for i := 0; i < 5; i++ {
c.SendMessage("/queue/sample", "text/plain", []byte(fmt.Sprintf("message: %d", i)))
}
}

// listen for incoming messages on subscription for destination /queue/sample
go consumer()

// send some messages to the broker on destination /queue/sample
go producer()

// wait for messages to be processed.
<-done
// get a reference to the event bus.
b := bus.GetBus()

// create a broker connector configuration, using WebSockets.
// Make sure you have a STOMP TCP server running like RabbitMQ
config := &bridge.BrokerConnectorConfig{
Username: "guest",
Password: "guest",
ServerAddr: ":61613",
STOMPHeader: map[string]string{
"access-token": "test",
},
}

// connect to broker.
c, err := b.ConnectBroker(config)
if err != nil {
fmt.Printf("unable to connect, error: %e", err)
}
defer c.Disconnect()

// subscribe to our demo simple-stream
s, _ := c.Subscribe("/queue/sample")

// set a counter
n := 0

// create a control chan
done := make(chan bool)

// listen for messages
var consumer = func() {
for {
// listen for incoming messages from subscription.
m := <-s.GetMsgChannel()
n++

// get byte array.
d := m.Payload.([]byte)

fmt.Printf("Message Received: %s\n", string(d))
// listen for 5 messages then stop.
if n >= 5 {
break
}
}
done <- true
}

// send messages
var producer = func() {
for i := 0; i < 5; i++ {
c.SendMessage("/queue/sample", "text/plain", []byte(fmt.Sprintf("message: %d", i)))
}
}

// listen for incoming messages on subscription for destination /queue/sample
go consumer()

// send some messages to the broker on destination /queue/sample
go producer()

// wait for messages to be processed.
<-done
}
124 changes: 62 additions & 62 deletions bridge/example_connector_broker_ws_test.go
Original file line number Diff line number Diff line change
@@ -4,70 +4,70 @@
package bridge_test

import (
"encoding/json"
"fmt"
"github.com/vmware/transport-go/bridge"
"github.com/vmware/transport-go/bus"
"github.com/vmware/transport-go/model"
"encoding/json"
"fmt"
"github.com/vmware/transport-go/bridge"
"github.com/vmware/transport-go/bus"
"github.com/vmware/transport-go/model"
)

func Example_connectUsingBrokerViaWebSocket() {

// get a reference to the event bus.
b := bus.GetBus()

// create a broker connector configuration, using WebSockets.
config := &bridge.BrokerConnectorConfig{
Username: "guest",
Password: "guest",
ServerAddr: "appfabric.vmware.com",
WebSocketConfig: &bridge.WebSocketConfig{WSPath: "/fabric"},
UseWS: true,
STOMPHeader: map[string]string{
"access-token": "test",
},
}

// connect to broker.
c, err := b.ConnectBroker(config)
if err != nil {
fmt.Printf("unable to connect, error: %e", err)
}

// subscribe to our demo simple-stream
s, _ := c.Subscribe("/topic/simple-stream")

// set a counter
n := 0

// create a control chan
done := make(chan bool)

var listener = func() {
for {
// listen for incoming messages from subscription.
m := <-s.GetMsgChannel()

// unmarshal message.
r := &model.Response{}
d := m.Payload.([]byte)
json.Unmarshal(d, &r)
fmt.Printf("Message Received: %s\n", r.Payload.(string))

n++

// listen for 5 messages then stop.
if n >= 5 {
break
}
}
done <- true
}

// listen for incoming messages on subscription.
go listener()

<-done

c.Disconnect()
// get a reference to the event bus.
b := bus.GetBus()

// create a broker connector configuration, using WebSockets.
config := &bridge.BrokerConnectorConfig{
Username: "guest",
Password: "guest",
ServerAddr: "appfabric.vmware.com",
WebSocketConfig: &bridge.WebSocketConfig{WSPath: "/fabric"},
UseWS: true,
STOMPHeader: map[string]string{
"access-token": "test",
},
}

// connect to broker.
c, err := b.ConnectBroker(config)
if err != nil {
fmt.Printf("unable to connect, error: %e", err)
}

// subscribe to our demo simple-stream
s, _ := c.Subscribe("/topic/simple-stream")

// set a counter
n := 0

// create a control chan
done := make(chan bool)

var listener = func() {
for {
// listen for incoming messages from subscription.
m := <-s.GetMsgChannel()

// unmarshal message.
r := &model.Response{}
d := m.Payload.([]byte)
json.Unmarshal(d, &r)
fmt.Printf("Message Received: %s\n", r.Payload.(string))

n++

// listen for 5 messages then stop.
if n >= 5 {
break
}
}
done <- true
}

// listen for incoming messages on subscription.
go listener()

<-done

c.Disconnect()
}
Loading