Skip to content
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

Switch to websockets for lightstreamer API #10

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions examples/lightstreamer/lightstreamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@ func main() {
return
}

tickChan := make(chan igmarkets.LightStreamerTick)
err := igHandle.OpenLightStreamerSubscription(ctx, conf.epics, tickChan)
lsConn, err := igHandle.NewLightStreamerConnection(ctx)
if err != nil {
log.Fatal(err)
}

err = igHandle.Login(ctx)

if err != nil {
log.Fatal(err)
}

tickChan, err := lsConn.SubscribeMarkets(ctx, conf.epics...)
if err != nil {
log.WithError(err).Error("open stream fialed")
}
Expand Down
9 changes: 8 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
module github.com/sklinkert/igmarkets

go 1.16
go 1.18

require (
github.com/AMekss/assert v0.0.0-20190715092210-758496b7ede5
github.com/cenkalti/backoff/v4 v4.3.0
github.com/gorilla/websocket v1.5.1
github.com/lfritz/env v1.0.0
github.com/sirupsen/logrus v1.9.3
)

require (
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
)
9 changes: 8 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
github.com/AMekss/assert v0.0.0-20190715092210-758496b7ede5 h1:mA6YQFIdUGmyjSCjo2WZeFcDwzR656KSnZcVY+Rv/t8=
github.com/AMekss/assert v0.0.0-20190715092210-758496b7ede5/go.mod h1:ndu6zhP6rGulhQRgV/7IxIsKVNT3xW8eVDzL+6v52QA=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/lfritz/env v1.0.0 h1:pC9f+uWck4B/Qy58VR/A8Uky/Ao0+r04S2bJ2PXgmpM=
github.com/lfritz/env v1.0.0/go.mod h1:/JdxpfISd4xqXGkZjPjRBuF8s2YVFjd2zko6xt9iF2w=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -12,8 +16,11 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions igmarkets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"reflect"
Expand Down Expand Up @@ -89,7 +89,7 @@ func (ig *IGMarkets) doRequestWithResponseHeaders(ctx context.Context, req *http
}
}()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return igResponse, nil, fmt.Errorf("igmarkets: unable to get body of transactions markets data: %v", err)
}
Expand Down
Loading
Loading