services

package
v0.0.0-...-24cbbce Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Copyright 2021 Wei (Sam) Wang <sam.wang.0723@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Wei (Sam) Wang <sam.wang.0723@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Wei (Sam) Wang <sam.wang.0723@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	RoundDecimalTwo = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CronjobConfig

type CronjobConfig struct {
	// The logger to use. If not defined an output-discarding logger will
	// be used instead.
	Logger *zerolog.Logger
}

Config encapsulates the settings for configuring the redis service.

type IService

type IService interface {
	BatchUpsertDailyClose(ctx context.Context, objs *[]interface{}) error
	ListDailyClose(
		ctx context.Context,
		req *dto.ListDailyCloseRequest,
	) ([]*entity.DailyClose, int64, error)
	HasDailyClose(ctx context.Context, date string) bool
	BatchUpsertStocks(ctx context.Context, objs *[]interface{}) error
	ListStock(ctx context.Context, req *dto.ListStockRequest) ([]*entity.Stock, int64, error)
	ListCategories(ctx context.Context) (objs []string, err error)
	ListSelections(ctx context.Context, req *dto.ListSelectionRequest) ([]*entity.Selection, error)
	BatchUpsertThreePrimary(ctx context.Context, objs *[]interface{}) error
	ListThreePrimary(
		ctx context.Context,
		req *dto.ListThreePrimaryRequest,
	) ([]*entity.ThreePrimary, int64, error)
	GetStakeConcentration(
		ctx context.Context,
		req *dto.GetStakeConcentrationRequest,
	) (*entity.StakeConcentration, error)
	BatchUpsertStakeConcentration(ctx context.Context, objs *[]interface{}) error
	ListeningKafkaInput(ctx context.Context)
	StopKafka() error
	StopRedis() error
	StartCron()
	StopCron()
	AddJob(ctx context.Context, spec string, job func()) error
	CronjobPresetRealtimeMonitoringKeys(ctx context.Context) error
	CrawlingRealTimePrice(ctx context.Context) error
	BatchUpsertPickedStocks(ctx context.Context, objs []*entity.PickedStock) error
	DeletePickedStockByID(ctx context.Context, stockID string) error
	ListPickedStock(ctx context.Context) ([]*entity.Selection, error)
	ObtainLock(ctx context.Context, key string, expire time.Duration) *redislock.Lock
	ListUsers(
		ctx context.Context,
		req *dto.ListUsersRequest,
	) (objs []*entity.User, totalCount int64, err error)
	GetUser(ctx context.Context) (obj *entity.User, err error)
	CreateUser(ctx context.Context, obj *entity.User) (err error)
	UpdateUser(ctx context.Context, obj *entity.User) (err error)
	Login(ctx context.Context, email, password string) (obj *entity.User, err error)
	Logout(ctx context.Context) error
	DeleteUser(ctx context.Context) (err error)
	GetUserByEmail(ctx context.Context, email string) (obj *entity.User, err error)
	GetUserByPhone(ctx context.Context, phone string) (obj *entity.User, err error)
	GetBalance(ctx context.Context) (obj *entity.BalanceView, err error)
	CreateTransaction(
		ctx context.Context,
		orderType string,
		creditAmount, debitAmount float32,
	) error
	CreateOrder(ctx context.Context, req *dto.CreateOrderRequest) error
	ListOrders(
		ctx context.Context,
		req *dto.ListOrderRequest,
	) (objs []*entity.Order, totalCount int64, err error)
	WithUserID(ctx context.Context) IService
}

func New

func New(opts ...Option) IService

type KafkaConfig

type KafkaConfig struct {
	Logger *zerolog.Logger

	GroupID string
	Brokers []string
	Topics  []string
}

Config encapsulates the settings for configuring the redis service.

type Option

type Option func(o *serviceImpl)

func WithCronJob

func WithCronJob(cfg CronjobConfig) Option

func WithDAL

func WithDAL(dal idal.IDAL) Option

func WithKafka

func WithKafka(cfg KafkaConfig) Option

func WithLogger

func WithLogger(logger *zerolog.Logger) Option

func WithProxy

func WithProxy(client *http.Client) Option

func WithRedis

func WithRedis(cfg RedisConfig) Option

type RedisConfig

type RedisConfig struct {
	// The logger to use. If not defined an output-discarding logger will
	// be used instead.
	Logger *zerolog.Logger
	// Redis master node DNS hostname
	Master string
	// Redis password
	Password string
	// Redis sentinel addresses
	SentinelAddrs []string
}

Config encapsulates the settings for configuring the redis service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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