middleware

package
v0.0.0-...-048b661 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: MIT Imports: 3 Imported by: 0

README

Synopsis

BenchmarkFinishEventNotifier

After starting the benchmark, the middleware that calls an arbitrary function when there are no more requests.

package main

import (
    middlewaretools "github.com/goccy/echo-tools/middleware"
    "github.com/labstack/echo/v4"
)

var (
	benchmarkFinishEventNotifier = middlewaretools.NewBenchmarkFinishEventNotifier(onBenchmarkFinished)
)

func startBenchmark(c echo.Context) error {
	benchmarkFinishEventNotifier.Start()
	return c.JSON(http.StatusOK, struct{}{})
}

func onBenchmarkFinished() {
	fmt.Println("benchmark finished")
}

func main() {
    e := echo.New()
    e.POST("/initialize", startBenchmark)
    e.Use(benchmarkFinishEventNotifier.Middleware())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BenchmarkFinishEventNotifier

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

func NewBenchmarkFinishEventNotifier

func NewBenchmarkFinishEventNotifier(onFinished func(), opts ...BenchmarkFinishEventNotifierOption) *BenchmarkFinishEventNotifier

func (*BenchmarkFinishEventNotifier) Middleware

func (n *BenchmarkFinishEventNotifier) Middleware() echo.MiddlewareFunc

func (*BenchmarkFinishEventNotifier) Start

func (n *BenchmarkFinishEventNotifier) Start()

type BenchmarkFinishEventNotifierOption

type BenchmarkFinishEventNotifierOption func(*BenchmarkFinishEventNotifier)

func BenchmarkFinishEventCheckInterval

func BenchmarkFinishEventCheckInterval(interval time.Duration) BenchmarkFinishEventNotifierOption

Jump to

Keyboard shortcuts

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