mirror of
https://github.com/Snawoot/opera-proxy.git
synced 2025-09-02 10:42:07 +00:00
fmt
This commit is contained in:
parent
ed153de1d0
commit
ddc27f34ab
3 changed files with 25 additions and 25 deletions
2
main.go
2
main.go
|
@ -208,7 +208,7 @@ func run() int {
|
||||||
}
|
}
|
||||||
cl()
|
cl()
|
||||||
|
|
||||||
runTicker(context.Background(), args.refresh, func (ctx context.Context) {
|
runTicker(context.Background(), args.refresh, func(ctx context.Context) {
|
||||||
mainLogger.Info("Refreshing login...")
|
mainLogger.Info("Refreshing login...")
|
||||||
loginCtx, cl := context.WithTimeout(ctx, args.timeout)
|
loginCtx, cl := context.WithTimeout(ctx, args.timeout)
|
||||||
defer cl()
|
defer cl()
|
||||||
|
|
|
@ -126,7 +126,7 @@ func (c *SEClient) AnonRegister(ctx context.Context) error {
|
||||||
func (c *SEClient) Register(ctx context.Context) error {
|
func (c *SEClient) Register(ctx context.Context) error {
|
||||||
var regRes SERegisterSubscriberResponse
|
var regRes SERegisterSubscriberResponse
|
||||||
err := c.RpcCall(ctx, c.Settings.Endpoints.RegisterSubscriber, StrKV{
|
err := c.RpcCall(ctx, c.Settings.Endpoints.RegisterSubscriber, StrKV{
|
||||||
"email": c.SubscriberEmail,
|
"email": c.SubscriberEmail,
|
||||||
"password": c.SubscriberPassword,
|
"password": c.SubscriberPassword,
|
||||||
}, ®Res)
|
}, ®Res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
46
utils.go
46
utils.go
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
COPY_BUF = 128 * 1024
|
COPY_BUF = 128 * 1024
|
||||||
WALLCLOCK_PRECISION = 1 * time.Second
|
WALLCLOCK_PRECISION = 1 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -148,30 +148,30 @@ func copyBody(wr io.Writer, body io.Reader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func AfterWallClock(d time.Duration) <-chan time.Time {
|
func AfterWallClock(d time.Duration) <-chan time.Time {
|
||||||
ch := make(chan time.Time, 1)
|
ch := make(chan time.Time, 1)
|
||||||
deadline := time.Now().Add(d).Truncate(0)
|
deadline := time.Now().Add(d).Truncate(0)
|
||||||
after_ch := time.After(d)
|
after_ch := time.After(d)
|
||||||
ticker := time.NewTicker(WALLCLOCK_PRECISION)
|
ticker := time.NewTicker(WALLCLOCK_PRECISION)
|
||||||
go func() {
|
go func() {
|
||||||
var t time.Time
|
var t time.Time
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case t = <-after_ch:
|
case t = <-after_ch:
|
||||||
ch <-t
|
ch <- t
|
||||||
return
|
return
|
||||||
case t = <-ticker.C:
|
case t = <-ticker.C:
|
||||||
if t.After(deadline) {
|
if t.After(deadline) {
|
||||||
ch <-t
|
ch <- t
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
func runTicker(ctx context.Context, interval time.Duration, cb func (context.Context)) {
|
func runTicker(ctx context.Context, interval time.Duration, cb func(context.Context)) {
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
Loading…
Add table
Reference in a new issue