gostream

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 6 Imported by: 1

README

gostream

PkgGoDev Go Report Card tests

  • Stream processing library for Go

TODO

  • Window
    • LengthWindow
    • LengthBatchWindow
    • TimeWindow
    • TimeBatchWindow
  • Select
  • Where
    • Equals, NotEquals
    • Larger, Less
    • AND, OR
  • OrderBy
  • Limit, Offset
  • Aggregate Function
    • Avg, Sum, Count
    • Max, Min

Example

type LogEvent struct {
  Time    time.Time
  Level   int
  Message string
}

q := "select * from LogEvent.length(10)"
s, err := gostream.New().
  Add(LogEvent{}).
  Query(q)
if err != nil {
  panic(err)
}
defer s.Close()

go func() {
  for {
    fmt.Printf("%v\n", <-s.Output())
  }
}()

s.Input() <- LogEvent{
  Time: time.Now()
  Level: 1
  Message: "something happened"
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrEmptyRegistry = errors.New("type registry is empty")

Functions

This section is empty.

Types

type GoStream

type GoStream struct {
	// contains filtered or unexported fields
}

func New

func New(opt ...*Option) *GoStream

func (*GoStream) Add

func (s *GoStream) Add(typ any) *GoStream

func (*GoStream) Query

func (s *GoStream) Query(q string) (*stream.Stream, error)
Example
package main

import (
	"fmt"
	"time"

	"github.com/itsubaki/gostream"
)

func main() {
	type LogEvent struct {
		Time    time.Time
		Level   int
		Message string
	}

	s, err := gostream.
		New(&gostream.Option{
			Verbose: true,
		}).
		Add(LogEvent{}).
		Query("select * from LogEvent.length(10)")
	if err != nil {
		fmt.Printf("query: %v", err)
		return
	}
	defer s.Close()

	fmt.Println(s)

}
Output:

SELECT * FROM IDENT(LogEvent) . LENGTH ( INT(10) )
SELECT * FROM LogEvent.LENGTH(10)

type Option

type Option struct {
	Verbose bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL