service

package
v0.0.0-...-9e1b110 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicService

type BasicService interface {
	ServeHome() string
	ServeToys() string
	ServeCrypto() string
	ServeTinyURL() string
	ServePastebin() string
	ServeStorage() string
	ServeAbout() string
}

BasicService base service which retrun the static html

type BasicServiceImpl

type BasicServiceImpl struct{}

BasicServiceImpl Web static service implement

func (*BasicServiceImpl) AfterInject

func (bs *BasicServiceImpl) AfterInject() error

AfterInject do inject

func (*BasicServiceImpl) ServeAbout

func (bs *BasicServiceImpl) ServeAbout() string

ServeAbout return the `about`

func (*BasicServiceImpl) ServeCrypto

func (bs *BasicServiceImpl) ServeCrypto() string

ServeCrypto return the `toys/crypto`

func (*BasicServiceImpl) ServeHome

func (bs *BasicServiceImpl) ServeHome() string

ServeHome return the `home`

func (*BasicServiceImpl) ServePastebin

func (bs *BasicServiceImpl) ServePastebin() string

ServePastebin return the `toys/pastebin`

func (*BasicServiceImpl) ServeStorage

func (bs *BasicServiceImpl) ServeStorage() string

ServeStorage return the `toys/storage`

func (*BasicServiceImpl) ServeTinyURL

func (bs *BasicServiceImpl) ServeTinyURL() string

ServeTinyURL return the `toys/tinyurl`

func (*BasicServiceImpl) ServeToys

func (bs *BasicServiceImpl) ServeToys() string

ServeToys return the `toys`

type BlogService

type BlogService interface {
	URLSearch(uri string) (types.Blog, error)
	Parse(content string) string
	RecentBlogs() ([]types.Blog, error)
}

BlogService blog service

type BlogServiceImpl

type BlogServiceImpl struct {
	Config *config.Config `inject-name:"Config"`
	Logger log.Logger     `inject-name:"WebLogger"`
	// contains filtered or unexported fields
}

BlogServiceImpl Web PasteBin service implement

func (*BlogServiceImpl) AfterInject

func (bs *BlogServiceImpl) AfterInject() error

AfterInject do inject

func (*BlogServiceImpl) Parse

func (ps *BlogServiceImpl) Parse(content string) string

func (*BlogServiceImpl) RecentBlogs

func (bs *BlogServiceImpl) RecentBlogs() ([]types.Blog, error)

func (*BlogServiceImpl) URLSearch

func (bs *BlogServiceImpl) URLSearch(uri string) (types.Blog, error)

type CosService

type CosService interface {
	Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error
	CosBucketURL(ctx context.Context, req *pb.CosBucketURLReq) (*pb.CosBucketURLResp, error)
	CosPut(ctx context.Context, req *pb.CosPutReq) (*pb.CosPutResp, error)
	CosGet(ctx context.Context, req *pb.CosGetReq) (*pb.CosGetResp, error)
}

CosService cos service

type CosServiceImpl

type CosServiceImpl struct {
	Config *config.Config `inject-name:"Config"`
	Logger log.Logger     `inject-name:"WebLogger"`
	// contains filtered or unexported fields
}

CosServiceImpl COS service implement

func (*CosServiceImpl) AfterInject

func (cs *CosServiceImpl) AfterInject() error

AfterInject do inject

func (*CosServiceImpl) CosBucketURL

func (cs *CosServiceImpl) CosBucketURL(ctx context.Context, req *pb.CosBucketURLReq) (*pb.CosBucketURLResp, error)

CosBucketURL return the BucketURL

func (*CosServiceImpl) CosGet

func (cs *CosServiceImpl) CosGet(ctx context.Context, req *pb.CosGetReq) (*pb.CosGetResp, error)

CosGet get file from COS storage There is no need for server to do this, we can download from URI directly.

func (*CosServiceImpl) CosPut

func (cs *CosServiceImpl) CosPut(ctx context.Context, req *pb.CosPutReq) (*pb.CosPutResp, error)

CosGet put file to COS storage

func (*CosServiceImpl) Register

func (cs *CosServiceImpl) Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error

Register the service

type CryptoService

type CryptoService interface {
	Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error
	CryptoEncrypt(ctx context.Context, req *crypto.CryptoEncryptReq) (*crypto.CryptoEncryptResp, error)
	CryptoDecrypt(ctx context.Context, req *crypto.CryptoDecryptReq) (*crypto.CryptoDecryptResp, error)
}

CryptoService crypto service which encrypt and decrypt text

type CryptoServiceImpl

type CryptoServiceImpl struct {
	Config *config.Config `inject-name:"Config"`
	Logger log.Logger     `inject-name:"WebLogger"`
	// contains filtered or unexported fields
}

CryptoServiceImpl Web crypto service implement

func (*CryptoServiceImpl) AfterInject

func (cs *CryptoServiceImpl) AfterInject() error

AfterInject do inject

func (*CryptoServiceImpl) CryptoDecrypt

func (cs *CryptoServiceImpl) CryptoDecrypt(ctx context.Context, req *pb.CryptoDecryptReq) (*pb.CryptoDecryptResp, error)

CryptoDecrypt decrypt

func (*CryptoServiceImpl) CryptoEncrypt

func (cs *CryptoServiceImpl) CryptoEncrypt(ctx context.Context, req *pb.CryptoEncryptReq) (*pb.CryptoEncryptResp, error)

CryptoEncrypt encrypt

func (*CryptoServiceImpl) Register

func (cs *CryptoServiceImpl) Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error

Register the service

type MysqlService

type MysqlService interface {
	Sync2() error
	GetEngineG() *xorm.EngineGroup
}

MysqlService mysql service

type MysqlServiceImpl

type MysqlServiceImpl struct {
	Config    *config.Config `inject-name:"Config"`
	Logger    log.Logger     `inject-name:"MysqlLogger"`
	ZapLogger *zap.Logger    `inject-name:"ZapLogger"`
	EngineG   *xorm.EngineGroup
}

MysqlServiceImpl inplement of MysqlService

func (*MysqlServiceImpl) AfterInject

func (ms *MysqlServiceImpl) AfterInject() error

AfterInject inject

func (*MysqlServiceImpl) GetEngineG

func (ms *MysqlServiceImpl) GetEngineG() *xorm.EngineGroup

GetEngineG return Engine Group

func (*MysqlServiceImpl) Sync2

func (ms *MysqlServiceImpl) Sync2() error

Sync2 sync the db

type PastebinService

type PastebinService interface {
	Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error
	PastebinSubmit(ctx context.Context, req *pastebin.PastebinSubmitReq) (*pastebin.PastebinSubmitResp, error)
	URLSearch(turl string) (*table.Page, error)
	Parse(content, syntax string) string
	RecentPosts() ([]table.Page, error)
}

PastebinService pastebin service

type PastebinServiceImpl

type PastebinServiceImpl struct {
	Config *config.Config `inject-name:"Config"`
	Logger log.Logger     `inject-name:"WebLogger"`

	RedisSvc RedisService `inject-name:"RedisService"`
	MysqlSvc MysqlService `inject-name:"MysqlService"`

	TinyURLSvc TinyURLService `inject-name:"TinyURLService"`
	// contains filtered or unexported fields
}

PastebinServiceImpl Web PasteBin service implement

func (*PastebinServiceImpl) AfterInject

func (ps *PastebinServiceImpl) AfterInject() error

AfterInject do inject

func (*PastebinServiceImpl) Parse

func (ps *PastebinServiceImpl) Parse(content, syntax string) string

Parse the content to markdown... etc.

func (*PastebinServiceImpl) PastebinSubmit

PastebinSubmit the text to DB

func (*PastebinServiceImpl) RecentPosts

func (ps *PastebinServiceImpl) RecentPosts() ([]table.Page, error)

RecentPosts show the recent posts

func (*PastebinServiceImpl) Register

func (ps *PastebinServiceImpl) Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error

Register the service

func (*PastebinServiceImpl) URLSearch

func (ps *PastebinServiceImpl) URLSearch(turl string) (*table.Page, error)

URLSearch the origin content from DB by turl

type RedisService

type RedisService interface {
	Ping() error
	Set(string, string, time.Duration) error
	Get(string) (string, error)
	Del(string) error
	GetExpireAt(string) (time.Time, error)
}

RedisService redis service

type RedisServiceImpl

type RedisServiceImpl struct {
	Config *config.Config `inject-name:"Config"`
	Logger log.Logger     `inject-name:"RedisLogger"`
	// contains filtered or unexported fields
}

RedisServiceImpl inplement of RedisService

func (*RedisServiceImpl) AfterInject

func (rs *RedisServiceImpl) AfterInject() error

AfterInject do inject

func (*RedisServiceImpl) Del

func (rs *RedisServiceImpl) Del(key string) error

Del delete key

func (*RedisServiceImpl) Get

func (rs *RedisServiceImpl) Get(key string) (string, error)

Get get key

func (*RedisServiceImpl) GetExpireAt

func (rs *RedisServiceImpl) GetExpireAt(key string) (time.Time, error)

GetExpireAt get key expire-time

func (*RedisServiceImpl) Ping

func (rs *RedisServiceImpl) Ping() error

Ping check the connection

func (*RedisServiceImpl) Set

func (rs *RedisServiceImpl) Set(key string, token string, duration time.Duration) error

Set set key

type TinyURLService

type TinyURLService interface {
	Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error
	TinyURLEncode(ctx context.Context, req *tinyurl.TinyURLEncodeReq) (*tinyurl.TinyURLEncodeResp, error)
	TinyURLDecode(ctx context.Context, req *tinyurl.TinyURLDecodeReq) (*tinyurl.TinyURLDecodeResp, error)
	Encode(url string) string
	URLSearch(turl string) (string, error)
}

TinyURLService tinyurl service

type TinyURLServiceImpl

type TinyURLServiceImpl struct {
	Config *config.Config `inject-name:"Config"`
	Logger log.Logger     `inject-name:"WebLogger"`

	RedisSvc RedisService `inject-name:"RedisService"`
	MysqlSvc MysqlService `inject-name:"MysqlService"`
	// contains filtered or unexported fields
}

TinyURLServiceImpl Web TinyURL service implement

func (*TinyURLServiceImpl) AfterInject

func (ts *TinyURLServiceImpl) AfterInject() error

AfterInject do inject

func (*TinyURLServiceImpl) Encode

func (ts *TinyURLServiceImpl) Encode(url string) string

Encode return the encode string directly

func (*TinyURLServiceImpl) Register

func (ts *TinyURLServiceImpl) Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error

Register the service

func (*TinyURLServiceImpl) TinyURLDecode

TinyURLDecode return the origin-url of tiny-url

func (*TinyURLServiceImpl) TinyURLEncode

TinyURLEncode return the tiny-url of origin-url

func (*TinyURLServiceImpl) URLSearch

func (ts *TinyURLServiceImpl) URLSearch(turl string) (string, error)

URLSearch return the origin-url of tiny-url suffix

type TraceService

type TraceService interface {
	StartSpan(operationName string) opentracing.Span
	Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error
	Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
	Close() error

	GetTracer() trace.Trace
	FromGinContext(c *gin.Context, serviceName string) opentracing.Span
}

TraceService trace service

type TraceServiceImpl

type TraceServiceImpl struct {
	Config *config.Config `inject-name:"Config"`
	// contains filtered or unexported fields
}

TraceServiceImpl inplement of TraceService

func (*TraceServiceImpl) AfterInject

func (ts *TraceServiceImpl) AfterInject() error

AfterInject inject

func (*TraceServiceImpl) Close

func (ts *TraceServiceImpl) Close() error

Close the closer

func (*TraceServiceImpl) Extract

func (ts *TraceServiceImpl) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)

Extract return the tracer's impl

func (*TraceServiceImpl) FromGinContext

func (ts *TraceServiceImpl) FromGinContext(c *gin.Context, serviceName string) opentracing.Span

FromGinContext start a new span from gin context

func (*TraceServiceImpl) GetTracer

func (ts *TraceServiceImpl) GetTracer() trace.Trace

GetTracer return the tracer

func (*TraceServiceImpl) Inject

func (ts *TraceServiceImpl) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error

Inject return the tracer's impl

func (*TraceServiceImpl) StartSpan

func (ts *TraceServiceImpl) StartSpan(operationName string) opentracing.Span

StartSpan return the tracer's impl

type UserService

type UserService interface {
	Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error
	UserTest(ctx context.Context, req *user.UserTestReq) (*user.UserTestResp, error)
	UserRegister(ctx context.Context, req *user.UserRegisterReq) (*user.UserRegisterResp, error)
	UserAuth(ctx context.Context, req *user.UserAuthReq) (*user.UserAuthResp, error)
	UserRefresh(ctx context.Context, req *user.UserRefreshReq) (*user.UserRefreshResp, error)
	UserInfo(ctx context.Context, req *user.UserInfoReq) (*user.UserInfoResp, error)
}

UserService user service

type UserServiceImpl

type UserServiceImpl struct {
	Config   *config.Config `inject-name:"Config"`
	Logger   log.Logger     `inject-name:"GRPCLogger"`
	RedisSvc RedisService   `inject-name:"RedisService"`
	MysqlSvc MysqlService   `inject-name:"MysqlService"`
}

UserServiceImpl GRPC user service implement

func (*UserServiceImpl) AfterInject

func (us *UserServiceImpl) AfterInject() error

AfterInject do inject

func (*UserServiceImpl) Register

func (us *UserServiceImpl) Register(ctx context.Context, gsrv *grpc.Server, gwmux *runtime.ServeMux, opts []grpc.DialOption) error

Register the service

func (*UserServiceImpl) UserAuth

func (us *UserServiceImpl) UserAuth(ctx context.Context, req *pb.UserAuthReq) (*pb.UserAuthResp, error)

UserAuth auth

func (*UserServiceImpl) UserInfo

func (us *UserServiceImpl) UserInfo(ctx context.Context, req *pb.UserInfoReq) (*pb.UserInfoResp, error)

UserInfo user information

func (*UserServiceImpl) UserRefresh

func (us *UserServiceImpl) UserRefresh(ctx context.Context, req *pb.UserRefreshReq) (*pb.UserRefreshResp, error)

UserRefresh refresh token

func (*UserServiceImpl) UserRegister

func (us *UserServiceImpl) UserRegister(ctx context.Context, req *pb.UserRegisterReq) (*pb.UserRegisterResp, error)

UserRegister register

func (*UserServiceImpl) UserTest

func (us *UserServiceImpl) UserTest(ctx context.Context, req *pb.UserTestReq) (*pb.UserTestResp, error)

UserTest for test

Jump to

Keyboard shortcuts

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