Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarbugli committed Oct 2, 2024
1 parent 530bdbd commit e6b63ad
Show file tree
Hide file tree
Showing 23 changed files with 790 additions and 678 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
STREAM_API_KEY=892s22ypvt6m
STREAM_API_SECRET=5cssrefv55rs3cnkk38kfjam2k7c2ykwn4h79dqh66ym89gm65cxy4h9jx4cypd6
STREAM_BASE_URL=http://127.0.0.1:3030
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* @sachaarbonel
* @tbarbugli
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
max-parallel: 3
fail-fast: false
matrix:
goVer: ['1.18', '1.19', '1.20', '1.21', '1.22']
goVer: ['1.22']
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
.envrc

# vendored dependencies and binaries
vendor/
vendor/
76 changes: 0 additions & 76 deletions .golangci.yml

This file was deleted.

1 change: 1 addition & 0 deletions call.go

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

1 change: 1 addition & 0 deletions channel.go

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

1 change: 1 addition & 0 deletions chat.go

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

10 changes: 7 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const (
defaultTimeout = 6 * time.Second
)

func PtrTo[T any](v T) *T {
return &v
}

type Client struct {
BaseURL string
HTTP *http.Client `json:"-"`
Expand Down Expand Up @@ -63,7 +67,7 @@ func WithBaseUrl(baseURL string) ClientOption {
// is retrieved from STREAM_KEY and the secret from STREAM_SECRET
// environmental variables.
func NewClientFromEnvVars(options ...ClientOption) (*Client, error) {
return NewClient(os.Getenv("STREAM_KEY"), os.Getenv("STREAM_SECRET"), options...)
return NewClient(os.Getenv("STREAM_API_KEY"), os.Getenv("STREAM_API_SECRET"), options...)
}

// NewClient creates new stream chat api client.
Expand All @@ -76,12 +80,12 @@ func NewClient(apiKey, apiSecret string, options ...ClientOption) (*Client, erro
}

baseURL := DefaultBaseURL
if baseURLEnv := os.Getenv("STREAM_CHAT_URL"); strings.HasPrefix(baseURLEnv, "http") {
if baseURLEnv := os.Getenv("STREAM_BASE_URL"); strings.HasPrefix(baseURLEnv, "http") {
baseURL = baseURLEnv
}

timeout := defaultTimeout
if timeoutEnv := os.Getenv("STREAM_CHAT_TIMEOUT"); timeoutEnv != "" {
if timeoutEnv := os.Getenv("STREAM_HTTP_TIMEOUT"); timeoutEnv != "" {
i, err := strconv.Atoi(timeoutEnv)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit e6b63ad

Please sign in to comment.