pump

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 9 Imported by: 0

README

测试 chan source-filter-sink

如果想测试 onex-pump,可以使用以下代码来替换 Run

func (s preparedServer) Run() error {
	source := ext.NewChanSource(tickerChan(time.Second * 1))

	filter := flow.NewMap(addUTC, 1)

	sink := ext.NewStdoutSink()

	source.Via(filter).To(sink)
	return nil
}

func tickerChan(repeat time.Duration) chan any {
	ticker := time.NewTicker(repeat)
	oc := ticker.C
	nc := make(chan any)
	go func() {
		for range oc {
			nc <- &message{strconv.FormatInt(time.Now().UTC().UnixNano(), 10)}
		}
	}()
	return nc
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	KafkaOptions *genericoptions.KafkaOptions
	MongoOptions *genericoptions.MongoOptions
}

Config contains application-related configurations.

func (*Config) NewServer

func (cfg *Config) NewServer(ctx context.Context) (*Server, error)

NewServer initializes and returns a new Server instance.

type Server

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

Server represents the web server.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the server and listens for termination signals. It gracefully shuts down the server upon receiving a termination signal.

Jump to

Keyboard shortcuts

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