Skip to content

Commit

Permalink
Merge pull request #1 from ArshiaDadras/main
Browse files Browse the repository at this point in the history
add orca engine
  • Loading branch information
pedy4000 authored Oct 21, 2024
2 parents 6ab1099 + 17f7fe6 commit f3ee813
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 53 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ jobs:
test:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.23
steps:
- uses: actions/checkout@v2
- name: Set GOFLAGS to disable VCS
run: echo "GOFLAGS=-buildvcs=false" >> $GITHUB_ENV
- name: Enable Go modules
run: echo "GO111MODULE=on" >> $GITHUB_ENV
- name: Download dependencies
Expand Down
4 changes: 2 additions & 2 deletions services/area-gateways/area_gateways_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions services/eta/call_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (
EtaEngineV2
EtaEngineNostradamus
EtaEngineOcelot
EtaEngineOrca
)

// String casts the engine enum to its string value.
Expand All @@ -23,6 +24,8 @@ func (engine EtaEngine) String() string {
return "nostradamus"
case EtaEngineOcelot:
return "ocelot"
case EtaEngineOrca:
return "orca"
}
return "v1"
}
Expand Down
14 changes: 12 additions & 2 deletions services/eta/call_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@ package eta
import "testing"

func TestMartixEngineString(t *testing.T) {
t.Run("test enginev1", func(t *testing.T) {
t.Run("test engine v1", func(t *testing.T) {
if EtaEngineV1.String() != "v1" {
t.Fatal("EtaEngineV1 is not stringified correctly")
}
})
t.Run("test enginev2", func(t *testing.T) {
t.Run("test engine v2", func(t *testing.T) {
if EtaEngineV2.String() != "v2" {
t.Fatal("EtaEngineV2 is not stringified correctly")
}
})
t.Run("test engine nostradamus", func(t *testing.T) {
if EtaEngineNostradamus.String() != "nostradamus" {
t.Fatal("EtaEngineNostradamus is not stringified correctly")
}
})
t.Run("test engine ocelot", func(t *testing.T) {
if EtaEngineOcelot.String() != "ocelot" {
t.Fatal("EtaEngineOcelot is not stringified correctly")
}
})
t.Run("test engine orca", func(t *testing.T) {
if EtaEngineOrca.String() != "orca" {
t.Fatal("EtaEngineOrca is not stringified correctly")
}
})
}

func TestWithEngine(t *testing.T) {
Expand Down
18 changes: 8 additions & 10 deletions services/eta/eta.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/snapp-incubator/smapp-sdk-go/config"
"github.com/snapp-incubator/smapp-sdk-go/version"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
"io"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"

"github.com/snapp-incubator/smapp-sdk-go/config"
"github.com/snapp-incubator/smapp-sdk-go/version"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
)

// Interface consists of functions of different functionalities of ETA service. there are two implementation of this service.
Expand Down Expand Up @@ -125,13 +125,11 @@ func (c *Client) GetETAWithContext(ctx context.Context, points []Point, options
return ETA{}, fmt.Errorf("smapp eta: could not make a request due to this error: %s", err.Error())
}

//nolint
var responseSpan trace.Span
//nolint
ctx, responseSpan = otel.Tracer(c.tracerName).Start(ctx, "response-deserialization")
_, responseSpan = otel.Tracer(c.tracerName).Start(ctx, "response-deserialization")

defer func() {
_, _ = io.Copy(ioutil.Discard, response.Body)
_, _ = io.Copy(io.Discard, response.Body)
_ = response.Body.Close()
}()

Expand Down
4 changes: 2 additions & 2 deletions services/eta/eta_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion services/eta/eta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package eta

import (
"context"
"github.com/snapp-incubator/smapp-sdk-go/config"
"net/http"
"net/http/httptest"
"testing"
"time"

"github.com/snapp-incubator/smapp-sdk-go/config"
)

func TestNewETAClient(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions services/eta/options.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package eta

import (
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"net/http"

"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)

// ConstructorOption is a function type for customizing constructor behaviour in a fluent way.
Expand All @@ -28,4 +29,4 @@ func WithRequestOpenTelemetryTracing(tracerName string) ConstructorOption {
client.tracerName = tracerName
client.httpClient.Transport = otelhttp.NewTransport(client.httpClient.Transport)
}
}
}
3 changes: 2 additions & 1 deletion services/eta/options_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package eta

import (
"github.com/snapp-incubator/smapp-sdk-go/config"
"net/http"
"testing"
"time"

"github.com/snapp-incubator/smapp-sdk-go/config"
)

func TestWithURL(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions services/matrix/call_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (
MatrixEngineV1 MatrixEngine = iota
MatrixEngineV2
MatrixEngineOcelot
MatrixEngineOrca
)

// String casts the engine enum to its string value.
Expand All @@ -19,6 +20,8 @@ func (engine MatrixEngine) String() string {
return "v2"
case MatrixEngineOcelot:
return "ocelot"
case MatrixEngineOrca:
return "orca"
}
return "v1"
}
Expand Down
11 changes: 8 additions & 3 deletions services/matrix/call_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@ package matrix
import "testing"

func TestMartixEngineString(t *testing.T) {
t.Run("test enginev1", func(t *testing.T) {
t.Run("test engine v1", func(t *testing.T) {
if MatrixEngineV1.String() != "v1" {
t.Fatal("MatrixEngineV1 is not stringified correctly")
}
})
t.Run("test enginev2", func(t *testing.T) {
t.Run("test engine v2", func(t *testing.T) {
if MatrixEngineV2.String() != "v2" {
t.Fatal("MatrixEngineV2 is not stringified correctly")
}
})
t.Run("test engineOcelot", func(t *testing.T) {
t.Run("test engine ocelot", func(t *testing.T) {
if MatrixEngineOcelot.String() != "ocelot" {
t.Fatal("MatrixEngineOcelot is not stringified correctly")
}
})
t.Run("test engine orca", func(t *testing.T) {
if MatrixEngineOrca.String() != "orca" {
t.Fatal("MatrixEngineOrca is not stringified correctly")
}
})
}

func TestWithHeaders(t *testing.T) {
Expand Down
7 changes: 2 additions & 5 deletions services/matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -124,13 +123,11 @@ func (c *Client) GetMatrixWithContext(ctx context.Context, sources []Point, targ
return Output{}, fmt.Errorf("smapp matrix: could not make a request due to this error: %s", err.Error())
}

//nolint
var responseSpan trace.Span
//nolint
ctx, responseSpan = otel.Tracer(c.tracerName).Start(ctx, "response-deserialization")
_, responseSpan = otel.Tracer(c.tracerName).Start(ctx, "response-deserialization")

defer func() {
_, _ = io.Copy(ioutil.Discard, response.Body)
_, _ = io.Copy(io.Discard, response.Body)
_ = response.Body.Close()
}()

Expand Down
4 changes: 2 additions & 2 deletions services/matrix/matrix_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion services/matrix/matrix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package matrix

import (
"context"
"github.com/snapp-incubator/smapp-sdk-go/config"
"net/http"
"net/http/httptest"
"testing"
"time"

"github.com/snapp-incubator/smapp-sdk-go/config"
)

func TestNewMatrixClient(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion services/matrix/options.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package matrix

import (
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"net/http"

"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)

// ConstructorOption is a function type for customizing constructor behaviour in a fluent way.
Expand Down
3 changes: 2 additions & 1 deletion services/matrix/options_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package matrix

import (
"github.com/snapp-incubator/smapp-sdk-go/config"
"net/http"
"testing"
"time"

"github.com/snapp-incubator/smapp-sdk-go/config"
)

func TestWithURL(t *testing.T) {
Expand Down
Loading

0 comments on commit f3ee813

Please sign in to comment.