Skip to content

Commit

Permalink
orderbook/buffer: data integrity and resubscription pass (thrasher-co…
Browse files Browse the repository at this point in the history
…rp#910)

* orderbook/buffer: data integrity and resubscription pass

* btcmarkets: REMOVE THAT LIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIINE!!!!!!!!!!!!!!!!!

* buffer: reinstate publish, refaactor, invalidate more and comments

* buffer/orderbook: improve update and snapshot performance. Move Update type to orderbook package to util. pointer through entire function calls. (cleanup). Change action string to uint8 for easier comparison. Add parsing helper. Update current test benchmark comments.

* dispatch: change publish func to variadic id param

* dispatch: remove sender receiver wait time as this adds overhead and complexity. update tests.

* dispatch: don't create pointers for every job container

* rpcserver: fix assertion issues with data publishing change

* linter: fixes

* glorious: nits addr

* depth: change validation handling to incorporate and store err

* linter: fix more issues

* dispatch: fix race

* travis: update before fetching

* depth: wrap and return wrapped error in invalidate call and fix tests

* btcmarkets: fix commenting

* workflow: check

* workflow: check

* orderbook: check error

* buffer/depth: return invalidation error and fix tests

* gctcli: display errors on orderbook streams

* buffer: remove unused types

* orderbook/bitmex: shift function to bitmex

* orderbook: Add specific comments to unexported functions that don't have locking require locking.

* orderbook: restrict published data functionality to orderbook.Outbound interface

* common: add assertion failure helper for error

* dispatch: remove atomics, add mutex protection, remove add/remove worker, redo main tests

* dispatch: export function

* engine: revert and change sub logger to manager

* engine: remove old test

* dispatch: add common variable ;)

* btcmarket: don't overflow int in tests on 32bit systems

* ci: force 1.17.7 usage for go

* Revert "ci: force 1.17.7 usage for go"

This reverts commit af2f955.

* golangci: bump version add and remove linter items

* Revert "golangci: bump version add and remove linter items"

This reverts commit 3c98bff.

* dispatch: remove unsused mutex from mux

* order: slight optimizations

* nits: glorious

* dispatch: fix regression on uuid generation and input inline with master

* linter: fix

* linter: fix

* glorious: nit - rm slice segration

* account: fix test after merge

* coinbasepro: revert change

* account: close channel instead of needing a receiver, push alert in routine to prepare for waiter.

Co-authored-by: Ryan O'Hara-Reid <[email protected]>
  • Loading branch information
shazbert and Ryan O'Hara-Reid authored May 3, 2022
1 parent 8adbcd0 commit c6ad429
Show file tree
Hide file tree
Showing 48 changed files with 3,914 additions and 3,100 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ jobs:
key: ${{ runner.os }}-go-386-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-386-

- name: Update apt-get
run: sudo apt-get update

- name: Install gcc-multilib
run: sudo apt-get install gcc-multilib

Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ matrix:
script:
- export GOARCH=386
- export CGO_ENABLED=1
- sudo apt-get update
- sudo apt-get install gcc-multilib
- make test
after_success:
Expand Down
15 changes: 10 additions & 5 deletions cmd/gctcli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3437,8 +3437,12 @@ func getOrderbookStream(c *cli.Context) error {
return err
}

fmt.Printf("Orderbook stream for %s %s:\n\n", exchangeName,
resp.Pair.String())
fmt.Printf("Orderbook stream for %s %s:\n\n", exchangeName, resp.Pair)
if resp.Error != "" {
fmt.Printf("%s\n", resp.Error)
continue
}

fmt.Println("\t\tBids\t\t\t\tAsks")
fmt.Println()

Expand Down Expand Up @@ -3535,9 +3539,10 @@ func getExchangeOrderbookStream(c *cli.Context) error {
return err
}

fmt.Printf("Orderbook streamed for %s %s",
exchangeName,
resp.Pair.String())
fmt.Printf("Orderbook streamed for %s %s", exchangeName, resp.Pair)
if resp.Error != "" {
fmt.Printf("%s\n", resp.Error)
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ var (
errCannotSetInvalidTimeout = errors.New("cannot set new HTTP client with timeout that is equal or less than 0")
errUserAgentInvalid = errors.New("cannot set invalid user agent")
errHTTPClientInvalid = errors.New("custom http client cannot be nil")

// ErrTypeAssertFailure defines an error when type assertion fails
ErrTypeAssertFailure = errors.New("type assert failure")
)

// SetHTTPClientWithTimeout sets a new *http.Client with different timeout
Expand Down Expand Up @@ -444,3 +447,9 @@ func StartEndTimeCheck(start, end time.Time) error {

return nil
}

// GetAssertError returns additional information for when an assertion failure
// occurs.
func GetAssertError(required string, received interface{}) error {
return fmt.Errorf("%w from %T to %s", ErrTypeAssertFailure, received, required)
}
17 changes: 17 additions & 0 deletions common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,3 +675,20 @@ func TestParseStartEndDate(t *testing.T) {
t.Errorf("received %v, expected %v", err, nil)
}
}

func TestGetAssertError(t *testing.T) {
err := GetAssertError("*[]string", float64(0))
if err.Error() != "type assert failure from float64 to *[]string" {
t.Fatal(err)
}

err = GetAssertError("<nil>", nil)
if err.Error() != "type assert failure from <nil> to <nil>" {
t.Fatal(err)
}

err = GetAssertError("bruh", struct{}{})
if !errors.Is(err, ErrTypeAssertFailure) {
t.Fatalf("received: '%v' but expected: '%v'", err, ErrTypeAssertFailure)
}
}
Loading

0 comments on commit c6ad429

Please sign in to comment.