-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New web-sockets
connector
#5170
Changes from all commits
0c39afd
6ab26f4
1899b85
f774a29
71523ac
162d334
2ebe548
7aa5793
42f28c7
d42c502
908ff49
48fa297
72ffd89
4d5cc99
ae1775f
fc3828f
a58411d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package factory | ||
|
||
import ( | ||
"github.com/multiversx/mx-chain-communication-go/websocket/data" | ||
"github.com/multiversx/mx-chain-communication-go/websocket/factory" | ||
"github.com/multiversx/mx-chain-core-go/marshal" | ||
"github.com/multiversx/mx-chain-go/config" | ||
"github.com/multiversx/mx-chain-go/outport" | ||
"github.com/multiversx/mx-chain-go/outport/host" | ||
logger "github.com/multiversx/mx-chain-logger-go" | ||
) | ||
|
||
type ArgsHostDriverFactory struct { | ||
HostConfig config.HostDriverConfig | ||
Marshaller marshal.Marshalizer | ||
} | ||
|
||
var log = logger.GetOrCreate("outport/factory/hostdriver") | ||
|
||
// CreateHostDriver will create a new instance of outport.Driver | ||
func CreateHostDriver(args ArgsHostDriverFactory) (outport.Driver, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing comments in the whole file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
wsHost, err := factory.CreateWebSocketHost(factory.ArgsWebSocketHost{ | ||
WebSocketConfig: data.WebSocketConfig{ | ||
URL: args.HostConfig.URL, | ||
WithAcknowledge: args.HostConfig.WithAcknowledge, | ||
Mode: args.HostConfig.Mode, | ||
RetryDurationInSec: args.HostConfig.RetryDurationInSec, | ||
BlockingAckOnError: args.HostConfig.BlockingAckOnError, | ||
}, | ||
Marshaller: args.Marshaller, | ||
Log: log, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return host.NewHostDriver(host.ArgsHostDriver{ | ||
Marshaller: args.Marshaller, | ||
SenderHost: wsHost, | ||
Log: log, | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package factory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing unit tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/multiversx/mx-chain-communication-go/websocket/data" | ||
"github.com/multiversx/mx-chain-go/config" | ||
"github.com/multiversx/mx-chain-go/testscommon" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCreateHostDriver(t *testing.T) { | ||
t.Parallel() | ||
|
||
args := ArgsHostDriverFactory{ | ||
HostConfig: config.HostDriverConfig{ | ||
URL: "localhost", | ||
RetryDurationInSec: 1, | ||
MarshallerType: "json", | ||
Mode: data.ModeClient, | ||
}, | ||
Marshaller: &testscommon.MarshalizerMock{}, | ||
} | ||
|
||
driver, err := CreateHostDriver(args) | ||
require.Nil(t, err) | ||
require.NotNil(t, driver) | ||
require.Equal(t, "*host.hostDriver", fmt.Sprintf("%T", driver)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a descriptive comment on what this does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added