J
J
jajabin2019-06-30 21:42:50
go
jajabin, 2019-06-30 21:42:50

How to re-initialize a variable with data from the database?

There is a server that receives data, after the packets no longer go, a true record is written to the bool type channel, then in the main program I wait for this value to arrive and execute some code, at the first start everything goes well, but when resent, the code is executed, the new data that is written in the table is not loaded, but the ones that were at the first start remain, I don’t understand how to force the request to be re-made.

for ok{

    var patterns = make(map[string]int)
    patterns = getPattern(hostDB,portDB)
    select {
    case <-stop:

      wg.Add(1)
      go sequencer.RunParseWorkers(workerCount,patterns, logCh, loaderCh, &wg)

      loaderNats, err := loader.NewLoader(subjectName, natsURL, loaderCh)
      if err != nil {
        log.Fatal(err)
      }
      wg.Add(1)
      go loaderNats.Run(&wg)
      ok = false
      

    }
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
uvelichitel, 2019-06-30
@jajabin

var patterns = make(map[string]int)
for {
    select (
        case <-stop:
            //do teardown
        default:
            //process data
   }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question