Skip to content

Commit ab496c5

Browse files
make vendor
1 parent f407259 commit ab496c5

File tree

24 files changed

+200
-201
lines changed

24 files changed

+200
-201
lines changed

api/routes/routes.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
179179
),
180180
)
181181

182-
/*
183-
for fetching list of users matching the query in the LDAP server
182+
/*
183+
for fetching list of users matching the query in the LDAP server
184184
supports URL params: q (Query)
185185
*/
186186
mux.Handle("GET /users/ldap/search", http.HandlerFunc(
@@ -193,7 +193,7 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
193193
allowedHeaders,
194194
),
195195
))
196-
196+
197197
/* handle OPTIONS preflight requests for /users/ldap/search */
198198
mux.HandleFunc("OPTIONS /users/ldap/search",
199199
middleware.CORSMiddleware(
@@ -209,8 +209,8 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
209209
),
210210
)
211211

212-
/*
213-
websocket connection for streaming user session data from Redis
212+
/*
213+
websocket connection for streaming user session data from Redis
214214
supports URL pamars: token (JWT authentication)
215215
*/
216216
mux.Handle("/users/session", http.HandlerFunc(
@@ -220,8 +220,8 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
220220
),
221221
))
222222

223-
/*
224-
websocket connection for streaming user transactions data from Redis
223+
/*
224+
websocket connection for streaming user transactions data from Redis
225225
supports URL pamars: token (JWT authentication)
226226
*/
227227
mux.Handle("/users/transactions/results", http.HandlerFunc(
@@ -230,8 +230,8 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
230230
),
231231
))
232232

233-
/*
234-
websocket connection for streaming user transactions data from Redis
233+
/*
234+
websocket connection for streaming user transactions data from Redis
235235
supports URL pamars: token (JWT authentication)
236236
*/
237237
mux.Handle("/users/transactions/pending", http.HandlerFunc(
@@ -304,7 +304,7 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
304304
),
305305
allowedOrigin,
306306
allowedMethods,
307-
allowedHeaders,
307+
allowedHeaders,
308308
),
309309
))
310310

cmd/laclm/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111
"time"
1212

1313
"github.com/MakeNowJust/heredoc"
14+
"github.com/jackc/pgx/v5/pgxpool"
1415
"github.com/joho/godotenv"
1516
"github.com/spf13/cobra"
1617
"go.uber.org/automaxprocs/maxprocs"
1718
"go.uber.org/zap"
1819
"google.golang.org/grpc"
1920
"google.golang.org/grpc/credentials/insecure"
2021
"google.golang.org/grpc/keepalive"
21-
"github.com/jackc/pgx/v5/pgxpool"
2222

2323
"github.com/PythonHacker24/linux-acl-management-backend/api/routes"
2424
"github.com/PythonHacker24/linux-acl-management-backend/config"

config/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type App struct {
1313
DebugMode bool `yaml:"debug_mode,omitempty"`
1414
SessionTimeout int `yaml:"session_timeout,omitempty"`
1515
BasePath string `yaml:"base_path,omitempty"`
16-
MaxWorkers int `yaml:"max_workers,omitempty"`
16+
MaxWorkers int `yaml:"max_workers,omitempty"`
1717
}
1818

1919
/* normalization function */

config/backend_security.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type BackendSecurity struct {
1111
JWTTokenSecret string `yaml:"jwt_secret_token,omitempty"`
1212

1313
/* make this obselete */
14-
JWTExpiry int `yaml:"jwt_expiry,omitempty"`
14+
JWTExpiry int `yaml:"jwt_expiry,omitempty"`
1515
}
1616

1717
/* normalization function */

config/database.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
/* database parameters */
1111
type Database struct {
1212
TransactionLogRedis TransactionLogRedis `yaml:"transaction_log_redis,omitempty"`
13-
ArchivalPQ ArchivalPQ `yaml:"archival_postgres,omitempty"`
13+
ArchivalPQ ArchivalPQ `yaml:"archival_postgres,omitempty"`
1414
}
1515

1616
/* transaction log redis parameters */
@@ -22,12 +22,12 @@ type TransactionLogRedis struct {
2222

2323
/* archival PostgreSQL parameters */
2424
type ArchivalPQ struct {
25-
Host string `yaml:"host,omitempty"`
26-
Port int `yaml:"port,omitempty"`
27-
User string `yaml:"user,omitempty"`
28-
Password string `yaml:"password,omitempty"`
29-
DBName string `yaml:"dbname,omitempty"`
30-
SSLMode string `yaml:"sslmode,omitempty"`
25+
Host string `yaml:"host,omitempty"`
26+
Port int `yaml:"port,omitempty"`
27+
User string `yaml:"user,omitempty"`
28+
Password string `yaml:"password,omitempty"`
29+
DBName string `yaml:"dbname,omitempty"`
30+
SSLMode string `yaml:"sslmode,omitempty"`
3131
}
3232

3333
/* normalization function for database */
@@ -41,7 +41,7 @@ func (d *Database) Normalize() error {
4141
/* check if PostgreSQL parameters are valid */
4242
err = d.ArchivalPQ.Normalize()
4343
if err != nil {
44-
return err
44+
return err
4545
}
4646

4747
return nil
@@ -73,33 +73,33 @@ func (a *ArchivalPQ) Normalize() error {
7373

7474
/* return localhost if empty */
7575
if a.Host == "" {
76-
a.Host = "localhost"
77-
}
76+
a.Host = "localhost"
77+
}
7878

7979
/* return default port if empty */
80-
if a.Port == 0 {
81-
a.Port = 5432
82-
}
80+
if a.Port == 0 {
81+
a.Port = 5432
82+
}
8383

8484
/* username is mandatory */
85-
if a.User == "" {
86-
return errors.New("Database username is not set in the configuration.")
87-
}
85+
if a.User == "" {
86+
return errors.New("Database username is not set in the configuration.")
87+
}
8888

8989
/* dbname is mandatory */
90-
if a.DBName == "" {
91-
return errors.New("Database name (dbname) is not set in the configuration.")
92-
}
90+
if a.DBName == "" {
91+
return errors.New("Database name (dbname) is not set in the configuration.")
92+
}
9393

9494
/* sslmode is disabled by default */
95-
if a.SSLMode == "" {
96-
a.SSLMode = "disable"
97-
}
95+
if a.SSLMode == "" {
96+
a.SSLMode = "disable"
97+
}
9898

9999
/* empty password but give a warning */
100-
if a.Password == "" {
101-
fmt.Printf("Warning: Connecting to PostgreSQL without a password. Consider using one for security.\n\n")
102-
}
100+
if a.Password == "" {
101+
fmt.Printf("Warning: Connecting to PostgreSQL without a password. Consider using one for security.\n\n")
102+
}
103103

104-
return nil
104+
return nil
105105
}

internal/auth/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func LoginHandler(sessionManager *session.Manager) http.HandlerFunc {
4444
return
4545
}
4646

47-
/*
47+
/*
4848
check if the session already exists in the manager.
4949
if it exists, refresh it's timer and return a jwt token
5050
*/
@@ -85,7 +85,7 @@ func LoginHandler(sessionManager *session.Manager) http.HandlerFunc {
8585
/* handles user logout and expire session */
8686
func LogoutHandler(sessionManager *session.Manager) http.HandlerFunc {
8787
return func(w http.ResponseWriter, r *http.Request) {
88-
88+
8989
/* authenticate the request through JWT */
9090
username, _, err := token.ExtractDataFromRequest(r)
9191
if err != nil {

internal/grpcpool/clientpool.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import (
88

99
/* creates a new client pool */
1010
func NewClientPool(opts ...grpc.DialOption) *ClientPool {
11-
return &ClientPool{
12-
conns: make(map[string]*grpc.ClientConn),
13-
dialOptions: opts,
14-
stopCh: make(chan struct{}),
15-
}
11+
return &ClientPool{
12+
conns: make(map[string]*grpc.ClientConn),
13+
dialOptions: opts,
14+
stopCh: make(chan struct{}),
15+
}
1616
}
1717

18-
/*
19-
creates a connection to given server
18+
/*
19+
creates a connection to given server
2020
allows multiple connections to be established to daemons for any transactions in execution
2121
*/
22-
func (p *ClientPool) GetConn(addr string, errCh chan<-error) (*grpc.ClientConn, error) {
22+
func (p *ClientPool) GetConn(addr string, errCh chan<- error) (*grpc.ClientConn, error) {
2323
/* check if connection exists or not */
2424
p.mu.RLock()
2525
conn, exists := p.conns[addr]
@@ -37,33 +37,33 @@ func (p *ClientPool) GetConn(addr string, errCh chan<-error) (*grpc.ClientConn,
3737
/* double check again (might been created between if exists and this line) */
3838
conn, exists = p.conns[addr]
3939
if exists {
40-
return conn, nil
41-
}
40+
return conn, nil
41+
}
4242

4343
/* create a new client for gRPC server */
4444
newConn, err := grpc.NewClient(addr, p.dialOptions...)
45-
if err != nil {
45+
if err != nil {
4646
return nil, fmt.Errorf("failed to add new connection: %w", err)
47-
}
47+
}
4848

4949
/* add connection to the pool */
50-
p.conns[addr] = newConn
50+
p.conns[addr] = newConn
5151

5252
/*
5353
in case of connection issues, it will remove itself from connection pool
54-
when connection is demanded again, whole logic written above will be executed again
54+
when connection is demanded again, whole logic written above will be executed again
5555
*/
5656
go p.MonitorHealth(addr, newConn, errCh)
57-
57+
5858
/* return connection */
59-
return newConn, nil
59+
return newConn, nil
6060
}
6161

62-
/*
62+
/*
6363
close all connections in the pool
6464
call this while error channel exists
6565
*/
66-
func (p *ClientPool) CloseAll(errCh chan<-error) {
66+
func (p *ClientPool) CloseAll(errCh chan<- error) {
6767
p.mu.Lock()
6868
defer p.mu.Unlock()
6969

internal/grpcpool/model.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package grpcpool
22

33
import (
4-
"sync"
54
"google.golang.org/grpc"
5+
"sync"
66
)
77

88
/* gRPC connection pool for daemons */
99
type ClientPool struct {
10-
mu sync.RWMutex
11-
conns map[string]*grpc.ClientConn
12-
dialOptions []grpc.DialOption
13-
stopCh chan struct{}
10+
mu sync.RWMutex
11+
conns map[string]*grpc.ClientConn
12+
dialOptions []grpc.DialOption
13+
stopCh chan struct{}
1414
}

internal/grpcpool/monitor.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
)
1212

1313
/* monitor gRPC connections */
14-
func (p *ClientPool) MonitorHealth(addr string, conn *grpc.ClientConn, errCh chan<-error) {
14+
func (p *ClientPool) MonitorHealth(addr string, conn *grpc.ClientConn, errCh chan<- error) {
1515
/* TODO: make it configurable */
16-
ticker := time.NewTicker(10 * time.Second)
16+
ticker := time.NewTicker(10 * time.Second)
1717
defer ticker.Stop()
1818

1919
for {
@@ -23,16 +23,16 @@ func (p *ClientPool) MonitorHealth(addr string, conn *grpc.ClientConn, errCh cha
2323
case <-ticker.C:
2424
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
2525
pingClient := pb.NewPingServiceClient(conn)
26-
_, err := pingClient.Ping(ctx, &pb.PingRequest{})
27-
cancel()
28-
26+
_, err := pingClient.Ping(ctx, &pb.PingRequest{})
27+
cancel()
28+
2929
if err != nil {
30-
errCh <- fmt.Errorf("ping failed for daemon at %s: %w", addr, err)
30+
errCh <- fmt.Errorf("ping failed for daemon at %s: %w", addr, err)
3131

3232
p.mu.Lock()
33-
conn.Close()
34-
delete(p.conns, addr)
35-
p.mu.Unlock()
33+
conn.Close()
34+
delete(p.conns, addr)
35+
p.mu.Unlock()
3636

3737
return
3838
} else {

internal/scheduler/fcfs/fcfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (f *FCFSScheduler) Run(ctx context.Context) error {
9393

9494
/* we assume the transaction has been processed -> updated Redis */
9595
transaction.Status = types.StatusSuccess
96-
96+
9797
/* update duration of transaction execution */
9898
elapsed := time.Since(transaction.Timestamp)
9999
transaction.DurationMs = elapsed.Milliseconds()

0 commit comments

Comments
 (0)