-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.go
More file actions
40 lines (35 loc) · 1.33 KB
/
Copy pathclient.go
File metadata and controls
40 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package pubsubrouter
import (
"context"
"github.com/sofyan48/pubsub-router/pkg/session"
)
type Config struct {
Type string `json:"type"`
ProjectID string `json:"project_id"`
PrivateKeyID string `json:"private_key_id"`
PrivateKey string `json:"private_key"`
ClientEmail string `json:"client_email"`
ClientID string `json:"client_id"`
AuthURI string `json:"auth_uri"`
TokenURI string `json:"token_uri"`
AuthProviderX509CertURL string `json:"auth_provider_x509_cert_url"`
ClientX509CertURL string `json:"client_x509_cert_url"`
}
func NewServer(ctx context.Context, cfg *Config) *Server {
sess := session.New(ctx, &session.Config{
Type: cfg.Type,
ProjectID: cfg.ProjectID,
PrivateKeyID: cfg.PrivateKeyID,
PrivateKey: cfg.PrivateKey,
ClientEmail: cfg.ClientEmail,
ClientID: cfg.ClientID,
AuthURI: cfg.AuthURI,
TokenURI: cfg.TokenURI,
AuthProviderX509CertURL: cfg.AuthProviderX509CertURL,
ClientX509CertURL: cfg.ClientX509CertURL,
})
return NewSession(ctx, sess)
}
func NewServerAutoConfig(ctx context.Context, projectID string) *Server {
return NewSessionAutoConfig(ctx, projectID)
}