service

package
v0.0.0-...-3e5fd69 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const DATATABLE = "data"
View Source
const INTABLE = "internals"
View Source
const ISSUEDB = "issuedb"
View Source
const ISSUETABLE = "issues"
View Source
const USERDB = "userdb"
View Source
const USERTABLE = "users"

Variables

View Source
var DialInfo = "localhost:50051"
View Source
var ErrNilInput = errors.New("nil in input")

helper converters

Functions

func AddChecksum

func AddChecksum(id string) (string, error)

func CreateMeta

func CreateMeta(name, desc string, isAvailable bool, paramDef map[string]string) *pb.CreateMetaResponse

func GetMeta

func GetMeta(id uint32) *pb.GetMetaResponse

func GetMethodExt

func GetMethodExt(x protoreflect.Message, serviceName, methodName string, xt protoreflect.ExtensionType) (*[]string, error)

helper for get extension sample to get IssueService.GetIssue's method_signature is below

ref := (&pb.Issue{}).ProtoReflect()
ms, err := GetMethodExt(ref, "IssueService", "GetIssue", pb.E_MethodSignature)
"issue_id" == ms[0] // should be true

func MaxEmv

func MaxEmv(p1 float32, d1 []int32, d2 []int32) int32

func NewId

func NewId() (string, error)

helpers about identity generation

func NewReport

func NewReport() *pb.Report

helper

func ReportMaxEmvResults

func ReportMaxEmvResults() *pb.Report

Types

type AnalyzeDBGetter

type AnalyzeDBGetter interface {
	GetDB() (*gorm.DB, error)
}

to inject db conn to repository

type AnalyzeRepository

type AnalyzeRepository interface {
	Init() error
	Fetch(ctx context.Context, id uint32) (*pb.Meta, error)
	Create(ctx context.Context, metaBody *pb.MetaBody) (*pb.Meta, error)
	Put(ctx context.Context, id uint32, metaBody *pb.MetaBody) (*pb.Meta, error)
	Delete(ctx context.Context, id uint32) (*pb.Meta, error)
	FetchFrom(ctx context.Context, id uint32) ([]uint32, error)
}

TODO: consider to refactor Repository, simplifly management DB inject or remove Repository interface(this interface can used when change to not rdb) repository

type AnalyzeServer

type AnalyzeServer struct {
	pb.AnalyzeServiceServer
	Repo AnalyzeRepository
}

server impl

func DefaultAnalyzeServerWithRepo

func DefaultAnalyzeServerWithRepo(ctx context.Context, repo AnalyzeRepository) *AnalyzeServer

constructors for server

func DefaultAnalyzeServiceServer

func DefaultAnalyzeServiceServer() *AnalyzeServer

func (*AnalyzeServer) CreateMeta

func (*AnalyzeServer) DeleteMeta

func (*AnalyzeServer) GetMeta

func (s *AnalyzeServer) GetMeta(ctx context.Context, in *pb.GetMetaRequest) (res *pb.GetMetaResponse, err error)

impl for GRPC interface

func (*AnalyzeServer) GetMetaList

func (*AnalyzeServer) GetMetrics

TODO

func (*AnalyzeServer) MaxEmv

func (*AnalyzeServer) PutMeta

type Config

type Config struct {
	Host          string `yaml:"host"`
	Port          int    `yaml:"port"`
	MysqlHost     string `yaml:"mysql_host"`
	MysqlPort     uint   `yaml:"mysql_port"`
	MysqlUser     string `yaml:"mysql_user"`
	MysqlPassword string `yaml:"mysql_password"`
	MysqlDbName   string `yaml:"mysql_dbname"`
}

func InitConfig

func InitConfig() (*Config, error)

type DefaultAnalyzeRepository

type DefaultAnalyzeRepository struct {
	DBGetter AnalyzeDBGetter
	Cache    *lru.Cache
}

to default func definition injectable conn

func (*DefaultAnalyzeRepository) Create

func (s *DefaultAnalyzeRepository) Create(ctx context.Context, metaBody *pb.MetaBody) (*pb.Meta, error)

func (*DefaultAnalyzeRepository) Delete

func (s *DefaultAnalyzeRepository) Delete(ctx context.Context, id uint32) (*pb.Meta, error)

func (*DefaultAnalyzeRepository) Fetch

func (s *DefaultAnalyzeRepository) Fetch(ctx context.Context, id uint32) (*pb.Meta, error)

func (*DefaultAnalyzeRepository) FetchFrom

func (s *DefaultAnalyzeRepository) FetchFrom(ctx context.Context, id uint32) ([]uint32, error)

func (*DefaultAnalyzeRepository) Init

func (s *DefaultAnalyzeRepository) Init() (err error)

func (*DefaultAnalyzeRepository) Put

func (s *DefaultAnalyzeRepository) Put(ctx context.Context, id uint32, metaBody *pb.MetaBody) (*pb.Meta, error)

type IssueRepository

type IssueRepository struct {
	RSess []*r.Session
	Rinfo string
	Cache *lru.Cache
}

func DefaultIssueRepository

func DefaultIssueRepository() *IssueRepository

func (*IssueRepository) AddCache

func (s *IssueRepository) AddCache(id string, vp interface{})

Add item to repository cache with id(internal recognize its type), value as pointer. When query passed as id, it maybe work even no support query base cache.

func (*IssueRepository) CreateData

func (s *IssueRepository) CreateData(ctx context.Context, data *pb.Data) (*pb.Data, error)

data for repository

func (*IssueRepository) CreateIssue

func (s *IssueRepository) CreateIssue(ctx context.Context, issue *pb.Issue) (*pb.Issue, error)

Issue

func (*IssueRepository) CreateUser

func (s *IssueRepository) CreateUser(ctx context.Context, user *pb.User) (*pb.User, error)

func (*IssueRepository) DeleteCache

func (s *IssueRepository) DeleteCache(id string, v interface{})

func (*IssueRepository) DeleteData

func (s *IssueRepository) DeleteData(ctx context.Context, dataId string) error

func (*IssueRepository) DeleteIssue

func (s *IssueRepository) DeleteIssue(ctx context.Context, issueId string) error

func (*IssueRepository) DeleteIssueInternal

func (s *IssueRepository) DeleteIssueInternal(ctx context.Context, issueId, childId, childType string) error

func (*IssueRepository) FetchData

func (s *IssueRepository) FetchData(ctx context.Context, dataId string) (*pb.Data, error)

func (*IssueRepository) FetchDataList

func (s *IssueRepository) FetchDataList(ctx context.Context, userId string) (data []*pb.Data, err error)

func (*IssueRepository) FetchIssue

func (s *IssueRepository) FetchIssue(ctx context.Context, issueId string) (*pb.Issue, error)

func (*IssueRepository) FetchIssues

func (s *IssueRepository) FetchIssues(ctx context.Context, userId string) ([]*pb.Issue, error)

func (*IssueRepository) FetchUser

func (s *IssueRepository) FetchUser(ctx context.Context, userId string) (*pb.User, error)

func (*IssueRepository) GetCache

func (s *IssueRepository) GetCache(id string, v interface{}) (interface{}, bool)

Get item from repository cache with id(internal, recognize its type), value as pointer

func (*IssueRepository) HardDeleteData

func (s *IssueRepository) HardDeleteData(ctx context.Context, dataId string) error

func (*IssueRepository) HardDeleteIssue

func (s *IssueRepository) HardDeleteIssue(ctx context.Context, issueId string) error

func (*IssueRepository) HardDeleteUser

func (s *IssueRepository) HardDeleteUser(ctx context.Context, userId string) error

func (*IssueRepository) Init

func (s *IssueRepository) Init() (err error)

func (*IssueRepository) PutData

func (s *IssueRepository) PutData(ctx context.Context, dataId string, data *pb.Data) (*pb.Data, error)

func (*IssueRepository) PutIssue

func (s *IssueRepository) PutIssue(ctx context.Context, issueId string, issue *pb.Issue) (*pb.Issue, error)

func (*IssueRepository) UnDeleteData

func (s *IssueRepository) UnDeleteData(ctx context.Context, dataId string) error

func (*IssueRepository) UnDeleteIssue

func (s *IssueRepository) UnDeleteIssue(ctx context.Context, issueId string) error

func (*IssueRepository) UnDeleteIssueInternal

func (s *IssueRepository) UnDeleteIssueInternal(ctx context.Context, issueId, childId, childType string) error

type IssueServiceServer

type IssueServiceServer struct {
	// embed service server interface, to check whether all interface impl, comment out and embed pb.UnsafeIssueServiceServer interface
	pb.IssueServiceServer
	Repo *IssueRepository
}

func DefaultIssueServiceServerWithRepo

func DefaultIssueServiceServerWithRepo(ctx context.Context, repo *IssueRepository) *IssueServiceServer

func (*IssueServiceServer) AddAnalyzedResult

func (*IssueServiceServer) CreateData

data

func (*IssueServiceServer) CreateIssue

func (s *IssueServiceServer) CreateIssue(ctx context.Context, in *pb.CreateIssueRequest) (res *pb.CreateIssueResponse, err error)

service

func (*IssueServiceServer) DecideBranch

func (*IssueServiceServer) DeleteData

func (*IssueServiceServer) DeleteIssue

func (s *IssueServiceServer) DeleteIssue(ctx context.Context, in *pb.DeleteIssueRequest) (res *pb.DeleteIssueResponse, err error)

func (*IssueServiceServer) DeleteIssueInternal

func (*IssueServiceServer) ExportIssue

func (s *IssueServiceServer) ExportIssue(ctx context.Context, in *pb.ExportIssueRequest) (res *pb.ExportIssueResponse, err error)

func (*IssueServiceServer) GetData

func (*IssueServiceServer) GetIssue

func (s *IssueServiceServer) GetIssue(ctx context.Context, in *pb.GetIssueRequest) (res *pb.GetIssueResponse, err error)

func (*IssueServiceServer) ListData

func (*IssueServiceServer) ListIssues

func (s *IssueServiceServer) ListIssues(ctx context.Context, in *pb.ListIssuesRequest) (res *pb.ListIssuesResponse, err error)

func (*IssueServiceServer) UnDeleteData

func (*IssueServiceServer) UnDeleteIssue

func (s *IssueServiceServer) UnDeleteIssue(ctx context.Context, in *pb.UnDeleteIssueRequest) (res *pb.UnDeleteIssueResponse, err error)

func (*IssueServiceServer) UnDeleteIssueInternal

func (*IssueServiceServer) UpdateData

func (*IssueServiceServer) UpdateIssue

func (s *IssueServiceServer) UpdateIssue(ctx context.Context, in *pb.UpdateIssueRequest) (res *pb.UpdateIssueResponse, err error)

type MaxEmvInput

type MaxEmvInput struct {
	P1  float32 `json:"p1"`
	DS1 []int32 `json:"ds1"`
	DS2 []int32 `json:"ds2"`
}

type Meta

type Meta struct {
	gorm.Model
	Name        string
	Desc        string
	IsAvailable bool   `gorm:"column:is_available"`
	ParamDef    string `gorm:"column:param_def"`
}

internal domain(model) compatible with rdb

type MysqlAnalyzeRepository

type MysqlAnalyzeRepository struct {
	*DefaultAnalyzeRepository
}

Mysql Repostitory

func NewMysqlAnalyzeRepository

func NewMysqlAnalyzeRepository(info *MysqlConnInfo) *MysqlAnalyzeRepository

constructor for mysql

type MysqlConnInfo

type MysqlConnInfo struct {
	User     string
	Password string
	Host     string
	Port     uint
	DbName   string
}

mysql conn info for Repository

func DefaultMysqlAnalyzeConnInfo

func DefaultMysqlAnalyzeConnInfo() *MysqlConnInfo

type MysqlDBGetter

type MysqlDBGetter struct {
	Info *MysqlConnInfo
}

func (*MysqlDBGetter) GetDB

func (s *MysqlDBGetter) GetDB() (*gorm.DB, error)

impl for GetDB abstruct func

type PyPayload

type PyPayload struct {
	Name string      `json:"name"`
	Data interface{} `json:"data"`
}

type ReportModel

type ReportModel struct {
	gorm.Model
	MaxEmv     int
	MaxEmvDesc string
	Seconds    int64
	Nanos      int32
}

domain model

type ReportRepository

type ReportRepository interface {
	Fetch() *pb.Report
	Put(*pb.Result)
}
var Repo ReportRepository

type Server

type Server struct {
	pb.GDeanServiceServer
}

server impl

func DefaultServer

func DefaultServer() *Server

func (*Server) ReportMaxEmvResults

func (s *Server) ReportMaxEmvResults(ctx context.Context, in *pb.ReportRequest) (*pb.ReportResponse, error)

type ServerWithRepo

type ServerWithRepo struct {
	Server *Server
	Repo   ReportRepository
}

func DefaultServerWithRepo

func DefaultServerWithRepo(ctx context.Context, server *Server, report ReportRepository) *ServerWithRepo

type Sqlite3ConnInfo

type Sqlite3ConnInfo string

func DefaultSqlite3ConnInfo

func DefaultSqlite3ConnInfo() *Sqlite3ConnInfo

type Sqlite3ReportRepository

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

func NewSqlite3ReportRepository

func NewSqlite3ReportRepository(filename *Sqlite3ConnInfo) *Sqlite3ReportRepository

func (Sqlite3ReportRepository) Fetch

func (r Sqlite3ReportRepository) Fetch() *pb.Report

func (Sqlite3ReportRepository) Put

func (r Sqlite3ReportRepository) Put(res *pb.Result)

type SqliteAnalyzeConnInfo

type SqliteAnalyzeConnInfo string

func DefaultSqliteAnalyzeConnInfo

func DefaultSqliteAnalyzeConnInfo() *SqliteAnalyzeConnInfo

type SqliteAnalyzeRepository

type SqliteAnalyzeRepository struct {
	*DefaultAnalyzeRepository
}

Repository implementation for rdb Sqlite Repoitory embedded Default(expext to injecte sqlite conn)

func NewSqliteAnalyzeRepository

func NewSqliteAnalyzeRepository(info *SqliteAnalyzeConnInfo) *SqliteAnalyzeRepository

constructor for sqlite

type SqlteDBGetter

type SqlteDBGetter struct {
	Info SqliteAnalyzeConnInfo
}

has conn info struct work with sqlite repository

func (*SqlteDBGetter) GetDB

func (s *SqlteDBGetter) GetDB() (*gorm.DB, error)

impl for GetDB abstruct func

type UserServiceServer

type UserServiceServer struct {
	pb.UserServiceServer
	// TODO: Separate from issue repository
	Repo *IssueRepository
}

func DefaultUserServiceServerWithRepo

func DefaultUserServiceServerWithRepo(ctx context.Context, repo *IssueRepository) *UserServiceServer

func (*UserServiceServer) CreateUser

Jump to

Keyboard shortcuts

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