I want to apply recursive to the code I created in the go language Announcing the arrival of...
What would be the ideal power source for a cybernetic eye?
Why aren't air breathing engines used as small first stages
How to find all the available tools in macOS terminal?
Why are there no cargo aircraft with "flying wing" design?
Is 1 ppb equal to 1 μg/kg?
Why is "Consequences inflicted." not a sentence?
When to stop saving and start investing?
How do I stop a creek from eroding my steep embankment?
Check which numbers satisfy the condition [A*B*C = A! + B! + C!]
What happens to sewage if there is no river near by?
How to bypass password on Windows XP account?
How can I fade player character when he goes inside or outside of the area?
How widely used is the term Treppenwitz? Is it something that most Germans know?
Bonus calculation: Am I making a mountain out of a molehill?
Is there a "higher Segal conjecture"?
3 doors, three guards, one stone
How do I keep my slimes from escaping their pens?
Does surprise arrest existing movement?
When is phishing education going too far?
What is this single-engine low-wing propeller plane?
Why was the term "discrete" used in discrete logarithm?
Does accepting a pardon have any bearing on trying that person for the same crime in a sovereign jurisdiction?
Using et al. for a last / senior author rather than for a first author
List *all* the tuples!
I want to apply recursive to the code I created in the go language
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Come Celebrate our 10 Year Anniversary!
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
enter image description here
I'm create program by golang like the picture above.
At first, we go through the authentication process and then main logic.
In main logic, I apply cron to execute it repeatedly.
problem is when http connection has lost.
If the http connection is lost in send data, I want to run the ping module and restart it from the first authentication.
Currently, I apply panic and recovery function and then recursive main().
Do you have a better idea?
package main
import (
"github.com/jasonlvhit/gocron"
"fmt"
"time"
)
var c = gocron.NewScheduler()
func authentication() bool {
fmt.Println("1.authentication")
return true
}
func collectData() {
fmt.Println("2.collectData")
}
func sendData() bool {
fmt.Println("3.sendData")
return false
}
func mainLogic(){
defer func() {
if r := recover(); r != nil {
fmt.Println("recovery")
main() ==> when ping result is success, I cause panic and then recursive call main() to restart from authentication.
}
}()
collectData()
if !sendData(){
if ping(true) {
c.Clear() // stop exist process of cron
panic("ping sucess")
}
}
}
func ping(pingResult bool) bool {
if pingResult {
fmt.Println("4.ping : true")
return pingResult
} else {
fmt.Println("4.ping : failed => retry after 3sec")
time.Sleep(3000000000)
ping(pingResult)
}
return pingResult
}
func main() {
c = gocron.NewScheduler()
if authentication() {
c.Every(5).Seconds().Do(mainLogic)
<-c.Start()
}
}
cron scheduled-task recursive go
add a comment |
enter image description here
I'm create program by golang like the picture above.
At first, we go through the authentication process and then main logic.
In main logic, I apply cron to execute it repeatedly.
problem is when http connection has lost.
If the http connection is lost in send data, I want to run the ping module and restart it from the first authentication.
Currently, I apply panic and recovery function and then recursive main().
Do you have a better idea?
package main
import (
"github.com/jasonlvhit/gocron"
"fmt"
"time"
)
var c = gocron.NewScheduler()
func authentication() bool {
fmt.Println("1.authentication")
return true
}
func collectData() {
fmt.Println("2.collectData")
}
func sendData() bool {
fmt.Println("3.sendData")
return false
}
func mainLogic(){
defer func() {
if r := recover(); r != nil {
fmt.Println("recovery")
main() ==> when ping result is success, I cause panic and then recursive call main() to restart from authentication.
}
}()
collectData()
if !sendData(){
if ping(true) {
c.Clear() // stop exist process of cron
panic("ping sucess")
}
}
}
func ping(pingResult bool) bool {
if pingResult {
fmt.Println("4.ping : true")
return pingResult
} else {
fmt.Println("4.ping : failed => retry after 3sec")
time.Sleep(3000000000)
ping(pingResult)
}
return pingResult
}
func main() {
c = gocron.NewScheduler()
if authentication() {
c.Every(5).Seconds().Do(mainLogic)
<-c.Start()
}
}
cron scheduled-task recursive go
add a comment |
enter image description here
I'm create program by golang like the picture above.
At first, we go through the authentication process and then main logic.
In main logic, I apply cron to execute it repeatedly.
problem is when http connection has lost.
If the http connection is lost in send data, I want to run the ping module and restart it from the first authentication.
Currently, I apply panic and recovery function and then recursive main().
Do you have a better idea?
package main
import (
"github.com/jasonlvhit/gocron"
"fmt"
"time"
)
var c = gocron.NewScheduler()
func authentication() bool {
fmt.Println("1.authentication")
return true
}
func collectData() {
fmt.Println("2.collectData")
}
func sendData() bool {
fmt.Println("3.sendData")
return false
}
func mainLogic(){
defer func() {
if r := recover(); r != nil {
fmt.Println("recovery")
main() ==> when ping result is success, I cause panic and then recursive call main() to restart from authentication.
}
}()
collectData()
if !sendData(){
if ping(true) {
c.Clear() // stop exist process of cron
panic("ping sucess")
}
}
}
func ping(pingResult bool) bool {
if pingResult {
fmt.Println("4.ping : true")
return pingResult
} else {
fmt.Println("4.ping : failed => retry after 3sec")
time.Sleep(3000000000)
ping(pingResult)
}
return pingResult
}
func main() {
c = gocron.NewScheduler()
if authentication() {
c.Every(5).Seconds().Do(mainLogic)
<-c.Start()
}
}
cron scheduled-task recursive go
enter image description here
I'm create program by golang like the picture above.
At first, we go through the authentication process and then main logic.
In main logic, I apply cron to execute it repeatedly.
problem is when http connection has lost.
If the http connection is lost in send data, I want to run the ping module and restart it from the first authentication.
Currently, I apply panic and recovery function and then recursive main().
Do you have a better idea?
package main
import (
"github.com/jasonlvhit/gocron"
"fmt"
"time"
)
var c = gocron.NewScheduler()
func authentication() bool {
fmt.Println("1.authentication")
return true
}
func collectData() {
fmt.Println("2.collectData")
}
func sendData() bool {
fmt.Println("3.sendData")
return false
}
func mainLogic(){
defer func() {
if r := recover(); r != nil {
fmt.Println("recovery")
main() ==> when ping result is success, I cause panic and then recursive call main() to restart from authentication.
}
}()
collectData()
if !sendData(){
if ping(true) {
c.Clear() // stop exist process of cron
panic("ping sucess")
}
}
}
func ping(pingResult bool) bool {
if pingResult {
fmt.Println("4.ping : true")
return pingResult
} else {
fmt.Println("4.ping : failed => retry after 3sec")
time.Sleep(3000000000)
ping(pingResult)
}
return pingResult
}
func main() {
c = gocron.NewScheduler()
if authentication() {
c.Every(5).Seconds().Do(mainLogic)
<-c.Start()
}
}
cron scheduled-task recursive go
cron scheduled-task recursive go
asked 1 min ago
염경훈염경훈
61
61
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f963225%2fi-want-to-apply-recursive-to-the-code-i-created-in-the-go-language%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f963225%2fi-want-to-apply-recursive-to-the-code-i-created-in-the-go-language%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown