Skip to content

Commit

Permalink
Merge pull request #10 from eh-steve/lightstreamer-websockets
Browse files Browse the repository at this point in the history
Switch to websockets for lightstreamer API
  • Loading branch information
sklinkert committed Jul 24, 2024
2 parents 7485fc7 + d40364a commit 1554435
Show file tree
Hide file tree
Showing 9 changed files with 1,036 additions and 118 deletions.
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

0 comments on commit 1554435

Please sign in to comment.