entity

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package entity provides entities for business logic.

Package entity provides entities for business logic.

Package entity provides entities for business logic.

Package entity provides entities for business logic.

Package entity provides entities for business logic.

Package entity provides entities for business logic.

Package entity provides entities for business logic.

Package entity provides entities for business logic.

Package entity provides entities for business logic.

Package entity provides entities for business logic.

Index

Constants

View Source
const (
	ReflectionServiceFQN         = "grpc.reflection.v1alpha.ServerReflection"
	MethodTypeUnary              = "u"
	MethodTypeClientStream       = "cs"
	MethodTypeServerStream       = "ss"
	MethodTypeClientServerStream = "css"
)

constants for gRPC client

View Source
const (
	ProtoTypeEnum    = "TYPE_ENUM"
	ProtoTypeMessage = "TYPE_MESSAGE"
)

protobuf types

View Source
const (
	TypeString   = "string"
	TypeBytes    = "bytes"
	TypeInt32    = "int32"
	TypeInt64    = "int64"
	TypeUInt32   = "uint32"
	TypeUInt64   = "uint64"
	TypeSInt32   = "sint32"
	TypeSInt64   = "sint64"
	TypeFixed32  = "fixed32"
	TypeFixed64  = "fixed64"
	TypeSFixed32 = "sfixed32"
	TypeSFixed64 = "sfixed64"
	TypeDouble   = "double"
	TypeFloat    = "float"
	TypeBool     = "bool"
	TypeEnum     = "enum"
	TypeMessage  = "message"
)

protobuf data types

Variables

View Source
var (
	// ErrWorkspaceNotExists error workspace not exists
	ErrWorkspaceNotExists = errors.New("workspace not exists")
)

Functions

func GetBool

func GetBool(f *Field, val interface{}) interface{}

GetBool transforms to bool

func GetBreadcrumb

func GetBreadcrumb(w []*Workspace, id int64) []string

GetBreadcrumb returns breadcrumb

func GetBytes

func GetBytes(f *Field, val interface{}) interface{}

GetBytes transforms to bytes

func GetFloat32

func GetFloat32(f *Field, val interface{}) (interface{}, error)

GetFloat32 transforms to float32

func GetFloat64

func GetFloat64(f *Field, val interface{}) (interface{}, error)

GetFloat64 transforms to float64

func GetInt32

func GetInt32(f *Field, val interface{}) (interface{}, error)

GetInt32 transforms to int32

func GetInt64

func GetInt64(f *Field, val interface{}) (interface{}, error)

GetInt64 transforms to int64

func GetString

func GetString(f *Field, val interface{}) interface{}

GetString transforms to string

func GetUInt32

func GetUInt32(f *Field, val interface{}) (interface{}, error)

GetUInt32 transforms to uint32

func GetUInt64

func GetUInt64(f *Field, val interface{}) (interface{}, error)

GetUInt64 transforms to uint64

func IsDebug

func IsDebug() bool

IsDebug returns true if application runs on debug mode

Types

type ApplicationConfig

type ApplicationConfig struct {
	Homepage        string `json:"homepage" default:"resources/index.html"`
	HomepageWin     string `json:"homepage_win" default:"../index.html"`
	IconsPath       string `json:"icons_path" default:"resources/icons"`
	AppIconLinux    string `json:"app_icon_linux" default:"app.png"`
	AppIconDarwin   string `json:"app_icon_darwin" default:"warthog.icns"`
	AppIconWindows  string `json:"app_icon_windows" default:"app.ico"`
	TrayIconLinux   string `json:"tray_icon_linux" default:"tray.png"`
	TrayIconDarwin  string `json:"tray_icon_darwin" default:"tray24.png"`
	TrayIconWindows string `json:"tray_icon_windows" default:"tray.ico"`
}

ApplicationConfig base application params

type Config

type Config struct {
	Application *ApplicationConfig `json:"application"`
	Database    *DatabaseConfig    `json:"database"`
	Grpc        *GrpcConfig        `json:"grpc"`
	Logger      *LoggerConfig      `json:"logger"`
	Runtime     *RuntimeConfig     `json:"runtime"`
}

Config application configuration

type DatabaseConfig

type DatabaseConfig struct {
	DatasourceName string `json:"datasource_name" default:"warthog.db"`
	DriverName     string `json:"driver_name" default:"sqlite3"`
}

DatabaseConfig database settings

type Enum

type Enum struct {
	ValueType string       `json:"value_type"`
	Values    []*EnumValue `json:"values"`
}

Enum protobuf enum

type EnumValue

type EnumValue struct {
	Name   string `json:"name"`
	Number int32  `json:"number"`
}

EnumValue protobuf enum value

type Error

type Error struct {
	Pos             ast.SourcePos `json:"pos"`
	Code            uint32        `json:"code"`
	CodeDescription string        `json:"code_description"`
	Message         string        `json:"message"`
}

Error UI error response

func (Error) Error

func (e Error) Error() string

Error returns error string

type Field

type Field struct {
	FQN        string                `json:"fqn"`
	ProtoFQN   string                `json:"proto_fqn"`
	Name       string                `json:"name"`
	Type       string                `json:"type"`
	ParentType string                `json:"parent_type"`
	Repeated   bool                  `json:"repeated"`
	Enum       *Enum                 `json:"enum,omitempty"`
	Map        *Map                  `json:"map,omitempty"`
	Message    *Message              `json:"message,omitempty"`
	OneOf      *OneOf                `json:"oneof,omitempty"`
	Descriptor *desc.FieldDescriptor `json:"-"`
}

Field protobuf field

type FolderRequest

type FolderRequest struct {
	ID         int64           `json:"id"`
	ParentID   *int64          `json:"parent_id"`
	Title      string          `json:"title"`
	TypeFilter []WorkspaceType `json:"type_filter"`
}

FolderRequest read/create/update/delete folder request

func (*FolderRequest) Model

func (r *FolderRequest) Model(folder map[string]interface{}) error

Model creates FolderRequest from UI request

type FolderResponse

type FolderResponse struct {
	Folder *Workspace           `json:"folder"`
	Tree   []*WorkspaceTreeNode `json:"tree"`
}

FolderResponse read/create/update folder response

type GUICommand

type GUICommand string

GUICommand UI command

const (
	CmdGetWorkspace        GUICommand = "workspace.get"
	CmdSortingWorkspace    GUICommand = "workspace.sorting"
	CmdDeleteWorkspace     GUICommand = "workspace.delete"
	CmdExpandWorkspace     GUICommand = "workspace.expand"
	CmdStateWorkspace      GUICommand = "workspace.state"
	CmdCreateServer        GUICommand = "server.create"
	CmdUpdateServer        GUICommand = "server.update"
	CmdUpdateServerRequest GUICommand = "server.update.request"
	CmdLoadServer          GUICommand = "server.load"
	CmdCreateFolder        GUICommand = "folder.create"
	CmdUpdateFolder        GUICommand = "folder.update"
	CmdDeleteFolder        GUICommand = "folder.delete"
	CmdUpdateQuery         GUICommand = "query.update"
	CmdRunQuery            GUICommand = "query.run"
	CmdCancelQuery         GUICommand = "query.cancel"
	CmdDevTools            GUICommand = "dev.tools.show"
	CmdMenuAbout           GUICommand = "menu.about"
)

UI events

func (GUICommand) String

func (c GUICommand) String() string

String returns UI command string

type GUIConfig

type GUIConfig struct {
	WindowWidth  int
	WindowHeight int
	WindowX      *int
	WindowY      *int
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

GUIConfig UI settings

type GUIRequest

type GUIRequest struct {
	Cmd     GUICommand             `json:"name"`
	Payload map[string]interface{} `json:"payload"`
}

GUIRequest UI request

type GUIResponse

type GUIResponse struct {
	Status  GUIResponseStatus `json:"status"`
	Error   Error             `json:"error,omitempty"`
	Payload interface{}       `json:"payload,omitempty"`
}

GUIResponse UI response

func ErrorGUIResponse

func ErrorGUIResponse(err error) *GUIResponse

ErrorGUIResponse returns UI error response

type GUIResponseStatus

type GUIResponseStatus string

GUIResponseStatus response status

const (
	GUIResponseStatusOK    GUIResponseStatus = "ok"
	GUIResponseStatusError GUIResponseStatus = "error"
)

UI response statuses

type GrpcConfig

type GrpcConfig struct {
	ConnectTimeout    int  `json:"connect_timeout" default:"10"`
	QueryTimeout      int  `json:"query_timeout" default:"30"`
	NonBlocking       bool `json:"non_blocking" default:"true"`
	SortMethodsByName bool `json:"sort_methods_by_name" default:"true"`
	MaxLoopDepth      int  `json:"max_loop_depth" default:"100"`
}

GrpcConfig gRPC settings

type LoadServerResponse

type LoadServerResponse struct {
	Server   *Workspace       `json:"server"`
	Services []*Service       `json:"services"`
	Query    *Workspace       `json:"query"`
	Warning  []*ProtobufError `json:"warning"`
}

LoadServerResponse server data, methods, and saved queries

type LoggerConfig

type LoggerConfig struct {
	Level             string `json:"level" default:"debug"`
	TimeFieldFormat   string `json:"time_field_format" default:"2006-01-02T15:04:05Z07:00"`
	PrettyPrint       bool   `json:"pretty_print" default:"true"`
	DisableSampling   bool   `json:"disable_sampling" default:"false"`
	RedirectStdLogger bool   `json:"redirect_std_logger" default:"false"`
	ErrorStack        bool   `json:"error_stack" default:"false"`
	ShowCaller        bool   `json:"show_caller" default:"false"`
}

LoggerConfig logger settings

type Map

type Map struct {
	KeyType         string                  `json:"key_type"`
	ValueType       string                  `json:"value_type"`
	ValueTypeFqn    string                  `json:"-"`
	ProtoValueType  string                  `json:"-"`
	ValueDescriptor *desc.MessageDescriptor `json:"-"`
	Fields          []*Field                `json:"fields,omitempty"`
}

Map protobuf map

type Message

type Message struct {
	Name       string                  `json:"name"`
	Type       string                  `json:"type"`
	Fields     []*Field                `json:"fields,omitempty"`
	Descriptor *desc.MessageDescriptor `json:"-"`
}

Message protobuf message

type Method

type Method struct {
	Name       string                 `json:"name"`
	Type       string                 `json:"type"`
	Input      []*Field               `json:"input,omitempty"`
	Descriptor *desc.MethodDescriptor `json:"-"`
}

Method gRPC method

type OneOf

type OneOf struct {
	Fqn  string `json:"fqn"`
	Name string `json:"name"`
}

OneOf protobuf oneof

type ProtobufError

type ProtobufError struct {
	Pos             ast.SourcePos `json:"pos"`
	Code            uint32        `json:"code"`
	CodeDescription string        `json:"code_description"`
	Warning         string        `json:"warning"`
	Err             error         `json:"err"`
}

ProtobufError protobuf parsing warning or error

func (ProtobufError) Error

func (pe ProtobufError) Error() string

Error returns error string

type Query

type Query struct {
	Service  string
	Method   string
	Data     map[string]interface{}
	Metadata []string
}

Query gRPC request

func (*Query) Model

func (r *Query) Model(server map[string]interface{}) error

Model creates Query from UI request

type QueryRequest

type QueryRequest struct {
	ID       int64  `json:"id"`
	ServerID int64  `json:"server_id"`
	Title    string `json:"title"`
	WorkspaceItemQuery
}

QueryRequest read/create/update/delete query

func (*QueryRequest) Model

func (r *QueryRequest) Model(req map[string]interface{}) error

Model creates QueryRequest from UI request

type QueryResponse

type QueryResponse struct {
	JsonString string              `json:"json_string"`
	SpentTime  string              `json:"spent_time"`
	Header     map[string][]string `json:"header"`
	Trailer    map[string][]string `json:"trailer"`
}

QueryResponse gRPC response

type RuntimeConfig

type RuntimeConfig struct {
	GoMaxProcs int `json:"go_max_procs" default:"0"`
}

RuntimeConfig runtime settings

type SavedQuery

type SavedQuery struct {
	Input    interface{} `json:"input"`
	Metadata interface{} `json:"metadata"`
}

SavedQuery saved query

func (*SavedQuery) Model

func (s *SavedQuery) Model(req map[string]interface{})

Model creates SavedQuery from UI request

type ServerRequest

type ServerRequest struct {
	ID       int64  `json:"id"`
	FolderID int64  `json:"folder_id"`
	Title    string `json:"title"`
	WorkspaceItemServer
}

ServerRequest read/create/delete server request

func (*ServerRequest) Model

func (r *ServerRequest) Model(req map[string]interface{}) error

Model creates ServerRequest from UI request

type ServerResponse

type ServerResponse struct {
	Server *Workspace           `json:"server"`
	Query  *Workspace           `json:"query"`
	Tree   []*WorkspaceTreeNode `json:"tree"`
}

ServerResponse read/create/update server response

type ServerUpdateRequest

type ServerUpdateRequest struct {
	ID      int64       `json:"id"`
	Service string      `json:"service"`
	Method  string      `json:"method"`
	Request *SavedQuery `json:"request"`
}

ServerUpdateRequest update server request

func (*ServerUpdateRequest) Model

func (r *ServerUpdateRequest) Model(req map[string]interface{}) error

Model creates ServerUpdateRequest from UI request

type Service

type Service struct {
	Name    string    `json:"name"`
	Methods []*Method `json:"methods,omitempty"`
}

Service gRPC service

type Workspace

type Workspace struct {
	ID         int64         `json:"id"`
	ParentID   *int64        `json:"parent_id"`
	HasChild   *bool         `json:"has_child"`
	Type       WorkspaceType `json:"type"`
	Title      string        `json:"text"`
	Breadcrumb []string      `json:"breadcrumb"`
	Data       interface{}   `json:"data"`
	Sort       *int          `json:"sort"`
	Expanded   *bool         `json:"expanded"`
	CreatedAt  time.Time     `json:"created_at"`
	UpdatedAt  time.Time     `json:"updated_at"`
}

Workspace workspace item

type WorkspaceExpandRequest

type WorkspaceExpandRequest struct {
	ID     int64 `json:"id"`
	Expand bool  `json:"expand"`
}

WorkspaceExpandRequest workspace expand/collapse request

func (*WorkspaceExpandRequest) Model

func (r *WorkspaceExpandRequest) Model(payload map[string]interface{}) error

Model creates WorkspaceExpandRequest from UI request

type WorkspaceItemFolder

type WorkspaceItemFolder struct {
}

WorkspaceItemFolder stored folder data

type WorkspaceItemQuery

type WorkspaceItemQuery struct {
	Service     string      `json:"service"`
	Method      string      `json:"method"`
	Description string      `json:"description"`
	Request     *SavedQuery `json:"request"`
}

WorkspaceItemQuery stored query data

func (*WorkspaceItemQuery) Model

func (s *WorkspaceItemQuery) Model(req map[string]interface{}) error

Model creates WorkspaceItemQuery from UI request

type WorkspaceItemServer

type WorkspaceItemServer struct {
	Addr              string                            `json:"addr,omitempty"`
	UseReflection     bool                              `json:"use_reflection,omitempty"`
	ProtoFiles        []string                          `json:"proto_files,omitempty"`
	ImportPath        []string                          `json:"import_path,omitempty"`
	NoTLS             bool                              `json:"no_tls,omitempty"`
	Insecure          bool                              `json:"insecure,omitempty"`
	RootCertificate   string                            `json:"root_certificate,omitempty"`
	ClientCertificate string                            `json:"client_certificate,omitempty"`
	ClientKey         string                            `json:"client_key,omitempty"`
	Request           map[string]map[string]*SavedQuery `json:"request"`
}

WorkspaceItemServer stored server data

func (*WorkspaceItemServer) Model

func (s *WorkspaceItemServer) Model(server map[string]interface{}) error

Model creates WorkspaceItemServer from UI request

type WorkspaceRequest

type WorkspaceRequest struct {
	Type []WorkspaceType `json:"type"`
}

WorkspaceRequest workspace request by type

func (*WorkspaceRequest) Model

func (r *WorkspaceRequest) Model(payload interface{}) error

Model creates WorkspaceRequest from UI request

type WorkspaceSortingRequest

type WorkspaceSortingRequest struct {
	Nodes []*Workspace `json:"nodes"`
}

WorkspaceSortingRequest workspace sorting request

func (*WorkspaceSortingRequest) Model

func (r *WorkspaceSortingRequest) Model(payload map[string]interface{}) error

Model creates WorkspaceSortingRequest from UI request

type WorkspaceState

type WorkspaceState struct {
	Folders            int    `json:"folders"`
	Servers            int    `json:"servers"`
	Queries            int    `json:"queries"`
	StartupWorkspaceID *int64 `json:"startup_workspace_id"`
}

WorkspaceState count of folders/servers/queries

type WorkspaceTreeFilter

type WorkspaceTreeFilter struct {
	Type []WorkspaceType
}

WorkspaceTreeFilter filtering workspace by type

type WorkspaceTreeNode

type WorkspaceTreeNode struct {
	Data  *Workspace           `json:"data"`
	Text  string               `json:"text"`
	Nodes []*WorkspaceTreeNode `json:"nodes"`
}

WorkspaceTreeNode workspace tree node

func MakeWorkspaceTree

func MakeWorkspaceTree(w []*Workspace, filter *WorkspaceTreeFilter) []*WorkspaceTreeNode

MakeWorkspaceTree creates workspace tree for UI

type WorkspaceType

type WorkspaceType string

WorkspaceType workspace type

const (
	WorkspaceTypeFolder WorkspaceType = "f"
	WorkspaceTypeServer WorkspaceType = "s"
	WorkspaceTypeQuery  WorkspaceType = "r"
)

workspace types

func (WorkspaceType) String

func (t WorkspaceType) String() string

String returns workspace type string

Jump to

Keyboard shortcuts

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