@@ -2,28 +2,25 @@ package transprocessor
22
33import (
44 "context"
5- "fmt"
6- "time"
75
86 "go.uber.org/zap"
97
8+ "github.com/PythonHacker24/linux-acl-management-backend/config"
9+ "github.com/PythonHacker24/linux-acl-management-backend/internal/grpcpool"
1010 "github.com/PythonHacker24/linux-acl-management-backend/internal/session"
1111 "github.com/PythonHacker24/linux-acl-management-backend/internal/types"
1212)
1313
1414/* instanciate new permission processor */
15- func NewPermProcessor (errCh chan <- error ) * PermProcessor {
15+ func NewPermProcessor (gRPCPool * grpcpool. ClientPool , errCh chan <- error ) * PermProcessor {
1616 return & PermProcessor {
17+ gRPCPool : gRPCPool ,
1718 errCh : errCh ,
1819 }
1920}
2021
2122/* processor for permissions manager */
22- func (p * PermProcessor ) Process (ctx context.Context , curSession * session.Session , tx interface {}) error {
23- transaction , ok := tx .(* types.Transaction )
24- if ! ok {
25- return fmt .Errorf ("invalid transaction type" )
26- }
23+ func (p * PermProcessor ) Process (ctx context.Context , curSession * session.Session , txn * types.Transaction ) error {
2724
2825 /* add complete information here + persistent logging in database */
2926 zap .L ().Info ("Processing Transaction" ,
@@ -32,10 +29,7 @@ func (p *PermProcessor) Process(ctx context.Context, curSession *session.Session
3229
3330 select {
3431 case <- ctx .Done ():
35- /*
36- store this into persistent storage too!
37- make sure database connections are closed after scheduler shutsdown
38- */
32+ /* close the processor */
3933 zap .L ().Warn ("Transaction process stopped due to shutdown" ,
4034 zap .String ("user" , curSession .Username ),
4135 )
@@ -46,12 +40,25 @@ func (p *PermProcessor) Process(ctx context.Context, curSession *session.Session
4640 remoteprocessor -> handles permissions on remote servers
4741 localprocessor -> handles permissions on local system (where this backend is deployed)
4842 */
49- _ = transaction
5043
51- /* for testing purposes only */
52- time .Sleep (5 * time .Second )
44+ isRemote , host , port , found , absolutePath := FindServerFromPath (config .BackendConfig .FileSystemServers , txn .TargetPath )
45+
46+ if ! found {
47+ /* filepath is invalid, filesystem doesn't exist */
48+ txn .ErrorMsg = "filesystem of given path doesn't exist"
49+ } else {
50+ if isRemote {
51+ /* handle through daemons */
52+ p .HandleRemoteTransaction (host , port , txn , absolutePath )
53+ } else {
54+ /* handle locally */
55+
56+ /* HandleLocalTransactions(txn) */
57+ }
58+ }
59+
5360 zap .L ().Info ("Completed Transaction" ,
54- zap .String ("ID" , transaction .ID .String ()),
61+ zap .String ("ID" , txn .ID .String ()),
5562 )
5663 }
5764
0 commit comments