Skip to content

Commit a9fd534

Browse files
authored
Signalling refactor (#701)
* v2 WIP * add attributes * WIP * envelope as one of * WIP * starting signalling interfaces * signal interface * clean up * clean up * clean up * deps * delete unused * staticheck config
1 parent cc45e29 commit a9fd534

31 files changed

+2007
-1321
lines changed

.github/workflows/buildtest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868
- name: Static Check
6969
uses: dominikh/staticcheck-action@master
7070
with:
71+
checks: '["all", "-ST1000", "-ST1003", "-ST1020", "-ST1021", "-ST1022", "-SA1019"]'
7172
install-go: false
7273

7374
- name: Mage Test

agent_client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/twitchtv/twirp"
1010

1111
"github.com/livekit/protocol/livekit"
12+
"github.com/livekit/server-sdk-go/v2/signalling"
1213
)
1314

1415
type AgentClient struct {
@@ -19,7 +20,7 @@ type AgentClient struct {
1920
func NewAgentClient(url string, apiKey string, apiSecret string, opts ...twirp.ClientOption) (*AgentClient, error) {
2021
serverUrl := os.Getenv("LK_AGENTS_URL")
2122
if serverUrl == "" {
22-
url = ToHttpURL(url)
23+
url = signalling.ToHttpURL(url)
2324
pattern := `^https?://[^.]+\.`
2425
re := regexp.MustCompile(pattern)
2526
serverUrl = re.ReplaceAllString(url, "https://agents.")

agent_dispatch_client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/twitchtv/twirp"
2222

2323
"github.com/livekit/protocol/livekit"
24+
"github.com/livekit/server-sdk-go/v2/signalling"
2425
)
2526

2627
type AgentDispatchClient struct {
@@ -29,7 +30,7 @@ type AgentDispatchClient struct {
2930
}
3031

3132
func NewAgentDispatchServiceClient(url string, apiKey string, secretKey string, opts ...twirp.ClientOption) *AgentDispatchClient {
32-
url = ToHttpURL(url)
33+
url = signalling.ToHttpURL(url)
3334
client := livekit.NewAgentDispatchServiceProtobufClient(url, &http.Client{}, opts...)
3435

3536
return &AgentDispatchClient{

auth.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ package lksdk
1616

1717
import (
1818
"context"
19-
"net/http"
2019

2120
"github.com/twitchtv/twirp"
2221

2322
"github.com/livekit/protocol/auth"
23+
"github.com/livekit/server-sdk-go/v2/signalling"
2424
)
2525

2626
type authBase struct {
@@ -61,11 +61,5 @@ func (b authBase) withAuth(ctx context.Context, opt authOption, options ...authO
6161
return nil, err
6262
}
6363

64-
return twirp.WithHTTPRequestHeaders(ctx, newHeaderWithToken(token))
65-
}
66-
67-
func newHeaderWithToken(token string) http.Header {
68-
header := make(http.Header)
69-
header.Set("Authorization", "Bearer "+token)
70-
return header
64+
return twirp.WithHTTPRequestHeaders(ctx, signalling.NewHeaderWithToken(token))
7165
}

egressclient.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/livekit/protocol/livekit"
2424
"github.com/livekit/protocol/utils/xtwirp"
25+
"github.com/livekit/server-sdk-go/v2/signalling"
2526
)
2627

2728
type EgressClient struct {
@@ -31,7 +32,7 @@ type EgressClient struct {
3132

3233
func NewEgressClient(url string, apiKey string, secretKey string, opts ...twirp.ClientOption) *EgressClient {
3334
opts = append(opts, xtwirp.DefaultClientOptions()...)
34-
url = ToHttpURL(url)
35+
url = signalling.ToHttpURL(url)
3536
client := livekit.NewEgressProtobufClient(url, &http.Client{}, opts...)
3637
return &EgressClient{
3738
egressClient: client,

0 commit comments

Comments
 (0)