kit

package
v1.6.5-rc46 Latest Latest
Warning

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

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

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(router *Router, transports ...Transport)

Types

type Client

type Client interface {
	Do(ctx context.Context, req interface{}, metas ...Metadata) Result
}

type ContextProvider

type ContextProvider interface {
	Operator
	ContextKey() interface{}
}

type ContextWith

type ContextWith = func(ctx context.Context) context.Context

func ComposeContextWith

func ComposeContextWith(withs ...ContextWith) ContextWith

type EmptyOperator

type EmptyOperator struct {
	OperatorWithoutOutput
}

type Metadata

type Metadata map[string][]string
Example
ma := Metadata{}
ma.Add("a", "Av1")
ma.Add("a", "Av2")

mb := Metadata{}
mb.Set("b", "Bv1")

all := FromMetas(ma, mb)

results := []interface{}{
	all.String(),
	all.Has("a"),
	all.Get("a"),
}

all.Del("b")

results = append(results,
	all.Get("b"),
	all.String(),
)

for _, r := range results {
	fmt.Printf("%v\n", r)
}
Output:

a=Av1&a=Av2&b=Bv1
true
Av1

a=Av1&a=Av2

func FromMetas

func FromMetas(metas ...Metadata) Metadata

func (Metadata) Add

func (m Metadata) Add(key, value string)

func (Metadata) Del

func (m Metadata) Del(key string)

func (Metadata) Get

func (m Metadata) Get(key string) string

func (Metadata) Has

func (m Metadata) Has(key string) bool

func (Metadata) Merge

func (m Metadata) Merge(metadata Metadata)

func (Metadata) Set

func (m Metadata) Set(key string, values ...string)

func (Metadata) String

func (m Metadata) String() string

type MetadataCarrier

type MetadataCarrier interface {
	Meta() Metadata
}

type MiddleOperators

type MiddleOperators []Operator

type Operator

type Operator interface {
	Output(ctx context.Context) (interface{}, error)
}

type OperatorFactory

type OperatorFactory struct {
	Type       reflect.Type
	ContextKey interface{}
	NoOutput   bool
	Params     url.Values
	IsLast     bool
	Operator   Operator
}

func NewOperatorFactory

func NewOperatorFactory(op Operator, last bool) *OperatorFactory

func (*OperatorFactory) New

func (o *OperatorFactory) New() Operator

func (*OperatorFactory) String

func (o *OperatorFactory) String() string

type OperatorInit

type OperatorInit interface {
	InitFrom(o Operator)
}

type OperatorNewer

type OperatorNewer interface {
	New() Operator
}

type OperatorWithParams

type OperatorWithParams interface {
	OperatorParams() map[string][]string
}

type OperatorWithoutOutput

type OperatorWithoutOutput interface {
	Operator
	NoOutput()
}

type Result

type Result interface {
	Into(v interface{}) (Metadata, error)
}

type Route

type Route struct {
	Operators []Operator
	// contains filtered or unexported fields
}

func (*Route) OperatorFactories

func (rs *Route) OperatorFactories() (factories []*OperatorFactory)

func (*Route) String

func (rs *Route) String() string

type Router

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

func NewRouter

func NewRouter(operators ...Operator) *Router

func (*Router) Register

func (r *Router) Register(x *Router)

func (*Router) Routes

func (r *Router) Routes() (routes Routes)

type Routes

type Routes []*Route

func (Routes) String

func (rs Routes) String() string

type Transport

type Transport interface {
	Serve(router *Router) error
}

type WithMiddleOperators

type WithMiddleOperators interface {
	MiddleOperators() MiddleOperators
}

Jump to

Keyboard shortcuts

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