-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
35 lines (29 loc) · 868 Bytes
/
server.go
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
package gapi
import (
"fmt"
worker "github.com/dbracic21-foi/simplebank/Worker"
db "github.com/dbracic21-foi/simplebank/db/sqlc"
"github.com/dbracic21-foi/simplebank/pb"
"github.com/dbracic21-foi/simplebank/token"
"github.com/dbracic21-foi/simplebank/util"
)
type Server struct {
pb.UnimplementedSimpleBankServer
config util.Config
store db.Store
tokenMaker token.Maker
taskDistributor worker.TaskDistributor
}
func NewServer(config util.Config, store db.Store, taskDistributor worker.TaskDistributor) (*Server, error) {
tokenMaker, err := token.NewPasetoMaker(config.TokenSymetricKey)
if err != nil {
return nil, fmt.Errorf("cannot make token :%w", err)
}
server := &Server{
config: config,
store: store,
tokenMaker: tokenMaker,
taskDistributor: taskDistributor,
}
return server, nil
}