Skip to content

Commit

Permalink
refactor: make code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
nlif-m committed Jul 9, 2023
1 parent cb7a3a6 commit cff3e2e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
)

func init() {
// Configure logger to write to the syslog. You could do this in init(), too.
// Configure logger to write to the syslog.
logwriter, e := syslog.New(syslog.LOG_NOTICE, "atomgen")
if e == nil {
log.SetOutput(logwriter)
Expand Down Expand Up @@ -52,21 +52,28 @@ func main() {
fullUpdateChan := make(chan bool)
atomFileUpdateChan := make(chan bool)

// Run initial update
go func(fullUpdateChan chan bool, atomFileUpdateChan chan bool) {
atomFileUpdateChan <- true
fullUpdateChan <- true
}(fullUpdateChan, atomFileUpdateChan)

// Run Telegram bot
go func() {
TgBot(atomgen, atomFileUpdateChan)
}()

var wg sync.WaitGroup

go func(fullUpdateChan chan bool, atomFileUpdateChan chan bool) {
go func() {
TgBot(atomgen, atomFileUpdateChan)
}()
for {
select {
case <-fullUpdateChan:
wg.Add(1)
atomgen.fullUpdate()
err = atomgen.fullUpdate()
utils.CheckErr(err)
err = atomgen.generateAtomFeed()
utils.CheckErr(err)
wg.Done()

case <-atomFileUpdateChan:
Expand Down

0 comments on commit cff3e2e

Please sign in to comment.