dal

package
v0.0.0-...-11e3e77 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID          primitive.ObjectID `bson:"_id" json:"id"`
	Name        string             `json:"name" bson:"name"`
	ServiceName string             `json:"service_name" bson:"service_name"`
	Description string             `json:"description" bson:"description"`
	RateLimit   float64            `json:"rate_limit" bson:"rate_limit"`
	IsAuth      bool               `json:"is_auth" bson:"is_auth"`
	Proxy       []Proxy            `json:"proxy" bson:"proxy"`
	Timeout     int                `json:"timeout" bson:"timeout"`
	Version     string             `json:"version" bson:"version"`
}

func (*Action) Validate

func (a *Action) Validate() error

type Basic

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

Basic implement Daler functions.

func (*Basic) Allow

func (b *Basic) Allow(ctx context.Context, key string, limit redis_rate.Limit) (*redis_rate.Result, error)

Allow

func (*Basic) CreateAction

func (b *Basic) CreateAction(ctx context.Context, action *Action) error

func (*Basic) DeleteActionByID

func (b *Basic) DeleteActionByID(ctx context.Context, id primitive.ObjectID) error

func (*Basic) DeleteActions

func (b *Basic) DeleteActions(ctx context.Context, ids []primitive.ObjectID) error

func (*Basic) FindActionByID

func (b *Basic) FindActionByID(ctx context.Context, id primitive.ObjectID) (*Action, error)

func (*Basic) FindActionByOpt

func (b *Basic) FindActionByOpt(ctx context.Context, opt FindActionOption) (*Action, error)

func (*Basic) ListActions

func (b *Basic) ListActions(ctx context.Context, opt ListActionOption) (*[]Action, int, error)

ListActions(ctx context.Context, opt ListActionOption) ([]*Action, error)

func (*Basic) UpdateAction

func (b *Basic) UpdateAction(ctx context.Context, action *Action) error

type Daler

type Daler interface {
	FindActionByOpt(ctx context.Context, opt FindActionOption) (*Action, error)
	UpdateAction(ctx context.Context, action *Action) error
	FindActionByID(ctx context.Context, id primitive.ObjectID) (*Action, error)
	DeleteActions(ctx context.Context, ids []primitive.ObjectID) error
	DeleteActionByID(ctx context.Context, id primitive.ObjectID) error
	ListActions(ctx context.Context, opt ListActionOption) (*[]Action, int, error)
	CreateAction(ctx context.Context, action *Action) error
	Allow(ctx context.Context, key string, limit redis_rate.Limit) (*redis_rate.Result, error)
}

Daler Collection of some database methods.

func NewDaler

func NewDaler(opt DalerOption) (Daler, error)

type DalerOption

type DalerOption struct {
	MongoDBURI  string
	MongoDBName string
	RedisURI    string
}

type FindActionOption

type FindActionOption struct {
	ServiceName string
	Version     string
	ActionName  string
}

type ListActionOption

type ListActionOption struct {
	PapeSize int64
	PageNum  int64
}

type Proxy

type Proxy struct {
	Scheme Scheme `json:"scheme" bson:"scheme"`
	Host   string `json:"host" bson:"host"`
	Path   string `json:"path" bson:"path"`
	Weight int    `json:"weight" bson:"weight"`
}

type Scheme

type Scheme string

Jump to

Keyboard shortcuts

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