admin

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware() gin.HandlerFunc

func NewAuthMiddleware

func NewAuthMiddleware(server *Server, realm, secretKey string) (*jwt.GinJWTMiddleware, error)

func Register

func Register(hook Hook)

Types

type ClusterDTO

type ClusterDTO struct {
	Name        string                `json:"name,omitempty"`
	Type        config.DataSourceType `json:"type"`
	SqlMaxLimit int                   `json:"sql_max_limit,omitempty"`
	Parameters  config.ParametersMap  `json:"parameters,omitempty"`
	Groups      []string              `json:"groups"`
}

type ConfigService

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

ConfigService represents a service to read/write configurations.

func GetService

func GetService(c *gin.Context) ConfigService

GetService returns ConfigService from gin context.

type GroupDTO

type GroupDTO struct {
	ClusterName string   `json:"clusterName,omitempty"`
	Name        string   `json:"name,omitempty"`
	Nodes       []string `json:"nodes,omitempty"`
}

type Handler

type Handler func(*gin.Context) error

type Hook

type Hook func(Router, Router)

type LoginPayload

type LoginPayload struct {
	Tenant   string `form:"tenant" json:"tenant"`
	Username string `form:"username" json:"username" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

type MyConfigService

type MyConfigService struct {
	TenantOp config.TenantOperator
	// contains filtered or unexported fields
}

func (*MyConfigService) BindNode

func (cs *MyConfigService) BindNode(ctx context.Context, tenant, cluster, group, node string) error

func (*MyConfigService) ListClusters

func (cs *MyConfigService) ListClusters(ctx context.Context, tenant string) ([]*ClusterDTO, error)

func (*MyConfigService) ListDBGroups

func (cs *MyConfigService) ListDBGroups(ctx context.Context, tenant, cluster string) ([]*GroupDTO, error)

func (*MyConfigService) ListNodes

func (cs *MyConfigService) ListNodes(ctx context.Context, tenant string) ([]*NodeDTO, error)

func (*MyConfigService) ListTables

func (cs *MyConfigService) ListTables(ctx context.Context, tenant, cluster string) ([]*TableDTO, error)

func (*MyConfigService) ListTenants

func (cs *MyConfigService) ListTenants(ctx context.Context) ([]*TenantDTO, error)

func (*MyConfigService) RemoveCluster

func (cs *MyConfigService) RemoveCluster(ctx context.Context, tenant, cluster string) error

func (*MyConfigService) RemoveGroup

func (cs *MyConfigService) RemoveGroup(ctx context.Context, tenant, cluster, group string) error

func (*MyConfigService) RemoveNode

func (cs *MyConfigService) RemoveNode(ctx context.Context, tenant, node string) error

func (*MyConfigService) RemoveTable

func (cs *MyConfigService) RemoveTable(ctx context.Context, tenant, cluster, table string) error

func (*MyConfigService) RemoveTenant

func (cs *MyConfigService) RemoveTenant(ctx context.Context, tenant string) error

func (*MyConfigService) RemoveUser

func (cs *MyConfigService) RemoveUser(ctx context.Context, tenant string, username string) error

func (*MyConfigService) UnbindNode

func (cs *MyConfigService) UnbindNode(ctx context.Context, tenant, cluster, group, node string) error

func (*MyConfigService) UpsertCluster

func (cs *MyConfigService) UpsertCluster(ctx context.Context, tenant, cluster string, body *ClusterDTO) error

func (*MyConfigService) UpsertGroup

func (cs *MyConfigService) UpsertGroup(ctx context.Context, tenant, cluster, group string, body *GroupDTO) error

func (*MyConfigService) UpsertNode

func (cs *MyConfigService) UpsertNode(ctx context.Context, tenant, node string, body *NodeDTO) error

func (*MyConfigService) UpsertTable

func (cs *MyConfigService) UpsertTable(ctx context.Context, tenant, cluster, table string, body *TableDTO) error

func (*MyConfigService) UpsertTenant

func (cs *MyConfigService) UpsertTenant(ctx context.Context, tenant string, body *TenantDTO) error

func (*MyConfigService) UpsertUser

func (cs *MyConfigService) UpsertUser(ctx context.Context, tenant string, user *config.User, username string) error

type NodeDTO

type NodeDTO struct {
	Name       string                 `json:"name,omitempty"`
	Host       string                 `json:"host"`
	Port       int                    `json:"port"`
	Username   string                 `json:"username"`
	Password   string                 `json:"password"`
	Database   string                 `json:"database"`
	Weight     string                 `json:"weight"`
	Parameters config.ParametersMap   `json:"parameters,omitempty"`
	ConnProps  map[string]interface{} `json:"conn_props,omitempty"`
	Labels     map[string]string      `json:"labels,omitempty"`
}

type Router

type Router interface {
	GET(string, Handler)
	POST(string, Handler)
	DELETE(string, Handler)
	PATCH(string, Handler)
	PUT(string, Handler)
}

type Server

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

func New

func New(tenantOp config.TenantOperator, serviceDiscovery base.Discovery) *Server

func (*Server) Close

func (srv *Server) Close() error

func (*Server) Listen

func (srv *Server) Listen(addr string) error

type ServiceDiscovery

type ServiceDiscovery interface {
	ListServices() []*ServiceInstanceDTO
}

func GetServiceDiscovery

func GetServiceDiscovery(c *gin.Context) ServiceDiscovery

GetServiceDiscovery returns ConfigService from gin context.

type ServiceInstanceDTO

type ServiceInstanceDTO struct {
	// ID is the unique instance ID as registered.
	ID string `json:"id"`
	// Name is the service name as registered.
	Name string `json:"name"`
	// Version is the version of the compiled.
	Version string `json:"version"`
	// Endpoint addresses of the service instance.
	Endpoint *config.Listener
}

type TableDTO

type TableDTO struct {
	Name           string            `json:"name,omitempty"`
	Sequence       *config.Sequence  `json:"sequence,omitempty"`
	AllowFullScan  bool              `json:"allow_full_scan,omitempty"`
	DbRules        []*config.Rule    `json:"db_rules,omitempty"`
	TblRules       []*config.Rule    `json:"tbl_rules,omitempty"`
	Topology       *config.Topology  `json:"topology,omitempty"`
	ShadowTopology *config.Topology  `json:"shadow_topology,omitempty"`
	Attributes     map[string]string `json:"attributes,omitempty"`
}

type TenantDTO

type TenantDTO struct {
	Name  string         `json:"name,omitempty"`
	Users []*config.User `json:"users"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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