base

package
v0.0.0-...-0350bc7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToJson

func AnyToJson(v any) []byte

func AnyToJsonString

func AnyToJsonString(v any) string

func Code

func Code(err error) codes.Code

func GetCaller

func GetCaller(skip int) uintptr

func GetCallerFrame

func GetCallerFrame(pc uintptr) runtime.Frame

func In

func In[T comparable](target T, sets ...T) bool

func NotFound

func NotFound(err error) bool

func NotIn

func NotIn[T comparable](target T, sets ...T) bool

func Zero

func Zero[T any]() T

func ZeroFromValue

func ZeroFromValue[T any](t T) T

Types

type Chain

type Chain[T any] []Interceptor[T]

func (Chain[T]) Do

func (chain Chain[T]) Do(c context.Context, req any, info T) (resp any, err error)

type Heap

type Heap[T any] struct {
	// contains filtered or unexported fields
}

func NewHeap

func NewHeap[T any](less func(t0, t1 T) bool, swaped func(t0, t1 T, i, j int)) *Heap[T]

func (*Heap[T]) Fix

func (h *Heap[T]) Fix(i int)

func (*Heap[T]) Init

func (h *Heap[T]) Init(x []T)

func (*Heap[T]) Pop

func (h *Heap[T]) Pop() T

func (*Heap[T]) Push

func (h *Heap[T]) Push(v T)

func (*Heap[T]) Range

func (h *Heap[T]) Range(f func(v T, i int) bool)

func (*Heap[T]) Remove

func (h *Heap[T]) Remove(i int) T

type Interceptor

type Interceptor[T any] interface {
	Handle(c context.Context, req any, info T, next Nexter[T]) (any, error)
}

type InterceptorFunc

type InterceptorFunc[T any] func(c context.Context, req any, info T, nexter Nexter[T]) (any, error)

func (InterceptorFunc[T]) Handle

func (h InterceptorFunc[T]) Handle(c context.Context, req any, info T, next Nexter[T]) (resp any, err error)

type Nexter

type Nexter[T any] struct {
	// contains filtered or unexported fields
}

func (Nexter[T]) LastHandler

func (n Nexter[T]) LastHandler() Interceptor[T]

func (Nexter[T]) Next

func (n Nexter[T]) Next(c context.Context, req any, info T) (resp any, err error)

type Status

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

func Convert

func Convert(err error) *Status

func FromError

func FromError(err error) (*Status, bool)

func New

func New(code codes.Code, event string) *Status

func (*Status) Err

func (s *Status) Err() error

func (*Status) GetCode

func (s *Status) GetCode() codes.Code

func (*Status) GetEvent

func (s *Status) GetEvent() string

func (*Status) GetMsg

func (s *Status) GetMsg() string

func (*Status) MarshalJSON

func (s *Status) MarshalJSON() ([]byte, error)

func (*Status) SetCode

func (s *Status) SetCode(code codes.Code) *Status

func (*Status) SetMsg

func (s *Status) SetMsg(format string, args ...any) *Status

type SyncMap

type SyncMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func (*SyncMap[K, V]) ClearAll

func (sm *SyncMap[K, V]) ClearAll()

func (*SyncMap[K, V]) Load

func (sm *SyncMap[K, V]) Load(k K) V

func (*SyncMap[K, V]) LoadOrStore

func (sm *SyncMap[K, V]) LoadOrStore(k K, v V) V

func (*SyncMap[K, V]) Store

func (sm *SyncMap[K, V]) Store(k K, v V)

Directories

Path Synopsis
Package semaphore provides a weighted semaphore implementation.
Package semaphore provides a weighted semaphore implementation.

Jump to

Keyboard shortcuts

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