-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
602 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package network | ||
|
||
import ( | ||
"context" | ||
"net" | ||
"time" | ||
|
||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
type TimeoutListener struct { | ||
net.Listener | ||
deadlineTimeout time.Duration | ||
} | ||
|
||
func (tl *TimeoutListener) Accept() (net.Conn, error) { | ||
conn, err := tl.Listener.Accept() | ||
if err != nil { | ||
return nil, err | ||
} | ||
if err = conn.SetDeadline(time.Now().Add(tl.deadlineTimeout)); err != nil { | ||
return nil, err | ||
} | ||
|
||
return conn, nil | ||
} | ||
|
||
func NewTimeoutListener( | ||
network, address string, | ||
timeout time.Duration, | ||
) (net.Listener, error) { | ||
lc := net.ListenConfig{} | ||
listener, err := lc.Listen(context.Background(), network, address) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &TimeoutListener{ | ||
Listener: listener, | ||
deadlineTimeout: timeout, | ||
}, nil | ||
} | ||
|
||
func CloseListener(l net.Listener) { | ||
err := l.Close() | ||
if err != nil { | ||
log.Error().Err(err).Msg("Failed to close listener") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
proxy/src/services/lunar-engine/actions/request_actions.model.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.