title: Trying to create an array and process it later at determined intarvals
body: <p>I am new to GoLang.  My app (being ported from nodejs) is consuming messages from Kafka.  Once i get a message, I inspect the config object in the message and place it in an array specific to that config.  The rest of the data of the message in placed in an array within that array.  Below are my structs</p>
  <pre><code>type ProcessArray struct {
      endpointDetails             MsgEndpoint
      lastUsed                    time.Time
      queue                       []Process
  }
  
  type Process struct {
      key                         string
      timings                     MsgTimings
      traceId                     string
      finalData                   json.RawMessage
  }
  </code></pre>
  <p>If the endpointDetails does not already exist, create a new array entry (this is being done).  Basically the endpointlDetails contains an id, mntDate, as well as url specific stuff.  lastUsed is updated anytime I add to the queue.</p>
  <p>What I want to do is every 100ms trigger a routine to process the queue (pull max of 100 messages from queue) for each endpointDetail (concurrently if possible).  This process will post an array of the messages to a REST api (max supported messages is 100).  Nothing has to be returned (errors and status are just logged, and errors will also be pushed back to Kafka).</p>
  <p>I come from a nodejs background, and I am doing this processing using a class as well as a timer in the class.  I know golang does not have classes, but I am coming up dark on how to get similar functionality.  For cleanup, if an endpoint has not been used in a set timeframe (5 mins), that endpoint needs to be removed from the array and no longer processed.  Also on program termination, any endpoint with existing queues needs to be process immediately.</p>
  <p>code so far:</p>
  <pre><code>var endpoints []ProcessArray
  
  func find(endpoint *MsgEndpoint) int {
      var index int = -1
      for i, c := range endpoints {
          if c.endpointDetails.Id == endpoint.Id &amp;&amp;
             c.endpointDetails.MntDate == endpoint.MntDate {
              index = i
              break
          }
      }
      return index
  }
  
  func ProcessLoad(msg OutputMessage, logger *zap.Logger) {
      newmsg := Process{
          key: msg.Key,
          timings: msg.Timings,
          traceId: msg.TraceId,
          finalData: msg.GQLdata,
      }
  
      i := find(&amp;msg.Config.Endpoint)
  
      if i == -1 {
          endpoints = append(endpoints, ProcessArray{
              endpointDetails: msg.Config.Endpoint,
              lastUsed: time.Now(),
              queue: make([]Process, 0),
          })
          endpoints[0].queue = append(endpoints[0].queue, newmsg)
      } else {
          endpoints[i].lastUsed = time.Now()
          endpoints[i].queue = append(endpoints[i].queue, newmsg)
      }
  }
  func ProcessData() {
  ...do REST API stuff here
  }
  </code></pre>