timeout

package
v2.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 6 Imported by: 0

README

Timeout - Jet Middleware

Timeout middleware for Jet.

Usage Example

package main

import (
	"context"
	"log"
	"time"

	"github.com/go-kratos-ecosystem/components/v2/hyperf/jet"
	"github.com/go-kratos-ecosystem/components/v2/hyperf/jet/middleware/timeout"
)

func main() {
	client, err := jet.NewClient(
		jet.WithTransporter(nil),
		// ...
	)
	if err != nil {
		log.Fatal(err)
	}

	// base usage
	client.Use(timeout.New()) // default 5s

	// custom timeout
	client.Use(timeout.New(
		timeout.Timeout(10 * time.Second),
	))

	// call service
	client.Invoke(context.Background(), "method", []any{"..."}, nil)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout = fmt.Errorf("jet/timeout: request timeout")
)

Functions

func New

func New(opts ...Option) jet.Middleware

Types

type Option

type Option func(*options)

func Timeout

func Timeout(timeout time.Duration) Option

Jump to

Keyboard shortcuts

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