oker

package
v0.0.0-...-fc67457 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("oker",
	fx.Provide(
		func(in telemetryIn) *telemetry {
			return &telemetry{
				logger:   in.Logger,
				counter:  in.Counter,
				duration: in.Duration,
			}
		}),
	fx.Provide(
		func(cfg Config, t *telemetry) (*Server, error) {
			a, err := New(
				WithConfig(cfg),
				AddOkEventListener(t),
			)

			return a, err
		},
	),
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Name string
}

type OkEvent

type OkEvent struct {
	// At holds the time when the request was made.
	At time.Time

	// PartnerID is the partner id of the request.
	PartnerID string

	// Duration is the time needed to ok the request.
	Duration time.Duration

	// StatusCode is the resulting http status code.
	StatusCode int

	// Error is the resulting error.
	Err error
}

OkEvent is the event that is sent about an ok request.

func (OkEvent) String

func (e OkEvent) String() string

type OkEventListener

type OkEventListener interface {
	OnOkEvent(OkEvent)
}

OkEventListener is the interface that must be implemented by types that want to receive FetchEvent notifications.

type OkEventListenerFunc

type OkEventListenerFunc func(OkEvent)

OkEventListenerFunc is a function type that implements OkEventListener. It can be used as an adapter for functions that need to implement the OkEventListener interface.

func (OkEventListenerFunc) OnEventEvent

func (f OkEventListenerFunc) OnEventEvent(e OkEvent)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func AddOkEventListener

func AddOkEventListener(listener OkEventListener, cancel ...*func()) Option

AddOkListener adds a listener for oking events. If the optional cancel parameter is provided, it is set to a function that can be used to cancel the listener.

func WithConfig

func WithConfig(c Config) Option

type Server

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

func New

func New(opts ...Option) (*Server, error)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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