source

package
v0.0.0-...-54421ad Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Overview

基於ISourceWorker 實現的數據源獲取類.

基本實現了基礎的功能,該類不能直接使用, 具體的類需要實現FechOnce方法用於獲取數據,本類相當於一個模板類

@author:bedewong @create at: @update at: 2019年4月20日 @change log:

@author:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSourceWorker

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

func NewBaseSourceWorker

func NewBaseSourceWorker(fn_ context.CancelFunc, ctx_ context.Context, code_ string) BaseSourceWorker

New BaseSourceWorker 对象

@param: 見 BaseSourceWorker 結構的聲明 @return:

func (*BaseSourceWorker) Cancel

func (this *BaseSourceWorker) Cancel()

控制协程结束执行

func (*BaseSourceWorker) FechOnce

func (this *BaseSourceWorker) FechOnce() ([]model.Tb_tick_data, error)

获取一条数据接口

留給具體類實現.

func (*BaseSourceWorker) FetchWork

func (this *BaseSourceWorker) FetchWork(ch chan<- []model.Tb_tick_data) error

協程工作,獲取tick數據.

循環每秒執行一次數據更新, 協程結束條件:外部控制 @param ch: 數據輸出通道. @return:

type ISourceWorker

type ISourceWorker interface {
	// 协程 执行的主方法
	FetchWork(chan<- []model.Tb_tick_data) error

	FechOnce() ([]model.Tb_tick_data, error)

	// 控制协程的结束
	Cancel()
}

* * 數據源woker接口類

type SinaSourceWorker

type SinaSourceWorker struct {
	BaseSourceWorker
	BaseUrl string
}

func NewSinaSourceWorker

func NewSinaSourceWorker(fn_ context.CancelFunc, ctx_ context.Context, code_ string, url string) SinaSourceWorker

创建对象

func (*SinaSourceWorker) FechOnce

func (this *SinaSourceWorker) FechOnce() ([]model.Tb_tick_data, error)

type TestSourceWorker

type TestSourceWorker struct {
	// 組合BaseWoker
	BaseSourceWorker
}

func NewTestSourceWorker

func NewTestSourceWorker(fn_ context.CancelFunc, ctx_ context.Context, code_ string) TestSourceWorker

New TestSourceWorker 对象

func (*TestSourceWorker) FechOnce

func (this *TestSourceWorker) FechOnce() ([]model.Tb_tick_data, error)

實現數據獲取方法.

本方法從數據獲取測試數據。

Jump to

Keyboard shortcuts

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