Documentation
¶
Index ¶
- Constants
- Variables
- func ChanSelect(selector Selector) bool
- func FuncEqual(func1, func2 any) bool
- func GetFunctionType[T any](f any) int
- func Handler(f StandardHandler, useS2S bool) func(w http.ResponseWriter, r *http.Request)
- func PushToQueue[R any](q *Queue, instance string, operation func() (any, error), out *Chan[R], ...)
- func RequestPost(ctx context.Context, endpoint, bearerToken string, body any, ...) ([]byte, error)
- func Returner(any)
- func WaitConcurrentExec[F egFunction[T], T any](threads ...*Thread[F, T])
- type Chan
- type HandleMap
- type IChan
- type KafkaConsumer
- type KafkaMessage
- type KafkaProducer
- type Queue
- type QueueObject
- type RawHandleMap
- type RawHandler
- type Selector
- type Server
- func (s *Server) Handle(apiEoute string, handler StandardHandler, useS2S bool) *Server
- func (s *Server) HandleAll(handleMap HandleMap) *Server
- func (s *Server) HandleAllWithS2S(handleMap HandleMap) *Server
- func (s *Server) HandleRaw(apiEoute string, handler RawHandler) *Server
- func (s *Server) HandleRawAll(handleMap RawHandleMap) *Server
- func (s *Server) Start()
- type Slice
- func (s *Slice[T]) Append(elems ...T) *Slice[T]
- func (s *Slice[T]) Copy() *Slice[T]
- func (s *Slice[T]) Cut(start, end int64) *Slice[T]
- func (s *Slice[T]) Enlarge(newSize int64)
- func (s *Slice[T]) Erase()
- func (s *Slice[T]) Extend(another *Slice[T]) *Slice[T]
- func (s *Slice[T]) Get(idx int64) T
- func (s *Slice[T]) IsEmpty() bool
- func (s *Slice[T]) Original() []T
- func (s *Slice[T]) Prepend(elems ...T) *Slice[T]
- func (s *Slice[T]) ResetToDefault()
- func (s *Slice[T]) Set(idx int64, value T)
- func (s *Slice[T]) Size() int64
- func (s *Slice[T]) Vanish()
- type StandardHandler
- type Thread
- func (t *Thread[F, T]) After(previous *Thread[F, T]) *Thread[F, T]
- func (t *Thread[F, T]) Function() F
- func (t *Thread[F, T]) MaybeStart(goInited bool) threadResult[T]
- func (t *Thread[F, T]) Position() int
- func (t *Thread[F, T]) Run()
- func (t *Thread[F, T]) SetExecuted()
- func (t *Thread[F, T]) Started() bool
- func (t *Thread[F, T]) String() string
- func (t *Thread[F, T]) Then(next *Thread[F, T]) *Thread[F, T]
Constants ¶
const ( S2SEnvKey = "EG_S2S_AUTH_KEY" S2SHeaderKey = "X-EG-S2S-Authorization" )
const ( EGFunctionTypeUnknown = iota EGFunctionTypeDefault EGFunctionTypeValue EGFunctionTypeResult )
Variables ¶
var ErrAuthFailed = errors.New("auth failed")
Functions ¶
func ChanSelect ¶
ChanSelect - like go select (NOTE: blocking call, size of selector must be min 1 and max 3 Chan + min 0 and max 1 SelectorDefault, otherwise panic) - returns true once the Returner is selected
func GetFunctionType ¶
func Handler ¶
func Handler(f StandardHandler, useS2S bool) func(w http.ResponseWriter, r *http.Request)
func PushToQueue ¶
func RequestPost ¶
func WaitConcurrentExec ¶
Types ¶
type Chan ¶
type Chan[T any] struct { // contains filtered or unexported fields }
Chan - user-friendly chan without "<-" and "->"
var SelectorDefault *Chan[selectorDefault]
func (*Chan[T]) AbstractOriginal ¶
AbstractOriginal - just don't use it, trust me
func (*Chan[T]) Close ¶
func (c *Chan[T]) Close()
Close - closes the Chan (below this point Write will be unavailable)
func (*Chan[T]) Original ¶
func (c *Chan[T]) Original() chan T
Original - get a go chan (not sure you really want it)
type HandleMap ¶
type HandleMap map[string]StandardHandler
type KafkaConsumer ¶
type KafkaConsumer struct {
// contains filtered or unexported fields
}
func NewKafkaConsumer ¶
func NewKafkaConsumer(brokers, groupID, topic, username, password string) *KafkaConsumer
func (*KafkaConsumer) Consume ¶
func (kp *KafkaConsumer) Consume(ctx context.Context) (*Chan[*KafkaMessage], error)
type KafkaMessage ¶
type KafkaProducer ¶
type KafkaProducer struct {
// contains filtered or unexported fields
}
func NewKafkaProducer ¶
func NewKafkaProducer(brokers, username, password string) *KafkaProducer
func (*KafkaProducer) Close ¶
func (kp *KafkaProducer) Close()
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
func NewRateLimitedQueue ¶
func (*Queue) TerminateQueue ¶
type QueueObject ¶
type QueueObject struct {
// contains filtered or unexported fields
}
type RawHandleMap ¶
type RawHandleMap map[string]RawHandler
type RawHandler ¶
type RawHandler func(w http.ResponseWriter, r *http.Request)
type Selector ¶
func (Selector) GetStructure ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Handle ¶
func (s *Server) Handle(apiEoute string, handler StandardHandler, useS2S bool) *Server
func (*Server) HandleAllWithS2S ¶
func (*Server) HandleRawAll ¶
func (s *Server) HandleRawAll(handleMap RawHandleMap) *Server
type Slice ¶
type Slice[T any] struct { // contains filtered or unexported fields }
Slice - user-friendly and concurrent-friendly slice []T without go-style crap like a = append(a, b)
func NewSlice ¶
NewSlice - create new Slice of type T - elems may be empty (NOTE: returns a pointer)
func NewSliceOfSize ¶
NewSlice - create new Slice of type with given go-slice capacity (NOTE: returns a pointer)
func WorkThreads ¶
func (*Slice[T]) Append ¶
Append - Python-styled "b = append(b, a)" operation - appends elems to the end of the inner go slice
func (*Slice[T]) Copy ¶
Copy - safe copy of the Slice object (NOTE: lock is not copied, so the return Slice is completely independent)
func (*Slice[T]) Cut ¶
Cut - panic-free slicing of the Slice - returns new Slice with the inner slice as example[start:end] (NOTE: start < end, start >= 0 and end < Size - otherwise it edits start and end to fit in bounds)
func (*Slice[T]) Enlarge ¶
Enlarge - adds some default values of T to the end, does nothing if newSize <= Size()
func (*Slice[T]) Erase ¶
func (s *Slice[T]) Erase()
Erase - drops all the values (size will be 0) but keeps capacity the same as size was
func (*Slice[T]) Extend ¶
Extend - the same as Append but joins two objects of eg.Slice - returns the first of them and keeps another unchanged
func (*Slice[T]) Get ¶
Get - panic-free "a = b[idx]" operation - returns value if idx is in bounds and default of type T otherwise
func (*Slice[T]) Original ¶
func (s *Slice[T]) Original() []T
Original - returns go slice from the inside (just in case you need it)
func (*Slice[T]) Prepend ¶
Prepend - Python-styled "b = append(a, b)" operation - appends elems before the inner go slice
func (*Slice[T]) ResetToDefault ¶
func (s *Slice[T]) ResetToDefault()
ResetToDefault - replaces all the values with default of type T (NOTE: not recommended, better use Erase())
func (*Slice[T]) Set ¶
Set - panic-free "b[idx] = a" operation - sets value if idx >= 0 and does nothing otherwise (NOTE: if idx >= Size(), it enlarges the Slice - see Enlarge())
type StandardHandler ¶
type Thread ¶
type Thread[F egFunction[T], T any] struct { // contains filtered or unexported fields }
func (*Thread[F, T]) MaybeStart ¶
func (*Thread[F, T]) SetExecuted ¶
func (t *Thread[F, T]) SetExecuted()