types.go raw

   1  // Package io contains the transport domains: an acceptor that owns the
   2  // listening socket, reader workers that own the read side and protocol
   3  // parsing of one connection at a time, and writer workers that own the write
   4  // side. Readers and writers communicate only with fixed channels.
   5  package io
   6  
   7  import (
   8  	"git.smesh.lol/torly/pkg/config"
   9  	tinyspawn "git.smesh.lol/torly/pkg/tinyspawn"
  10  	"git.smesh.lol/torly/pkg/wire"
  11  )
  12  
  13  // ReaderData is the per-worker startup configuration.
  14  type ReaderData struct {
  15  	Index int
  16  	Cfg   config.Config
  17  }
  18  
  19  // ReaderChans are the channels bound to a reader worker.
  20  type ReaderChans struct {
  21  	Assign tinyspawn.Duplex[wire.Assign]
  22  	In     tinyspawn.Duplex[wire.Inbound]
  23  	Ctl    tinyspawn.Duplex[wire.WriterCtl]
  24  	Ack    tinyspawn.Duplex[uint8]
  25  	Stop   tinyspawn.Breaker
  26  }
  27  
  28  // WriterData is the per-writer startup configuration.
  29  type WriterData struct {
  30  	Index int
  31  }
  32  
  33  // WriterChans are the channels bound to a writer worker.
  34  type WriterChans struct {
  35  	Ctl  tinyspawn.Duplex[wire.WriterCtl]
  36  	Out  tinyspawn.Duplex[wire.Outbound]
  37  	Ack  tinyspawn.Duplex[uint8]
  38  	Stop tinyspawn.Breaker
  39  }
  40  
  41  // AcceptorData is the accept domain's startup configuration.
  42  type AcceptorData struct {
  43  	Addr string
  44  	Cfg  config.Config
  45  }
  46  
  47  // AcceptorChans are the channels bound to the accept domain. Workers has one
  48  // assign duplex per reader worker; the acceptor is the only writer to them.
  49  type AcceptorChans struct {
  50  	Workers []tinyspawn.Duplex[wire.Assign]
  51  	Ready   chan<- wire.Ready
  52  	Stop    tinyspawn.Breaker
  53  }
  54