mx to writelog
This commit is contained in:
		
							parent
							
								
									877cb88bec
								
							
						
					
					
						commit
						734f7bbdfb
					
				
							
								
								
									
										46
									
								
								core.go
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								core.go
									
									
									
									
									
								
							| @ -182,11 +182,11 @@ func (core *Core) GetRedisLocalCli() (*redis.Client, error) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // 这些应该是放到 texus 里实现的 | // 这些应该是放到 texus 里实现的 | ||||||
| // func (core *Core) GetAllTickerInfo() (*rest.RESTAPIResult, error) { | func (core *Core) GetAllTickerInfo() (*rest.RESTAPIResult, error) { | ||||||
| // 	// GET / 获取所有产品行情信息 | 	// GET / 获取所有产品行情信息 | ||||||
| // 	rsp, err := core.RestInvoke("/api/v5/market/tickers?instType=SPOT", rest.GET) | 	rsp, err := core.RestInvoke("/api/v5/market/tickers?instType=SPOT", rest.GET) | ||||||
| // 	return rsp, err | 	return rsp, err | ||||||
| // } | } | ||||||
| 
 | 
 | ||||||
| // 这些跟 订单有关,都关掉 | // 这些跟 订单有关,都关掉 | ||||||
| // | // | ||||||
| @ -277,24 +277,24 @@ func (core *Core) v5PublicInvoke(subUrl string) (*CandleData, error) { | |||||||
| 	return &result, nil | 	return &result, nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // func (core *Core) RestInvoke(subUrl string, method string) (*rest.RESTAPIResult, error) { | func (core *Core) RestInvoke(subUrl string, method string) (*rest.RESTAPIResult, error) { | ||||||
| // 	restUrl, _ := core.Cfg.Config.Get("connect").Get("restBaseUrl").String() | 	restUrl, _ := core.Cfg.Config.Get("connect").Get("restBaseUrl").String() | ||||||
| // 	//ep, method, uri string, param *map[string]interface{} | 	//ep, method, uri string, param *map[string]interface{} | ||||||
| // 	rest := rest.NewRESTAPI(restUrl, method, subUrl, nil) | 	rest := rest.NewRESTAPI(restUrl, method, subUrl, nil) | ||||||
| // 	key, _ := core.Cfg.Config.Get("credentialReadOnly").Get("okAccessKey").String() | 	key, _ := core.Cfg.Config.Get("credentialReadOnly").Get("okAccessKey").String() | ||||||
| // 	secure, _ := core.Cfg.Config.Get("credentialReadOnly").Get("secretKey").String() | 	secure, _ := core.Cfg.Config.Get("credentialReadOnly").Get("secretKey").String() | ||||||
| // 	pass, _ := core.Cfg.Config.Get("credentialReadOnly").Get("okAccessPassphrase").String() | 	pass, _ := core.Cfg.Config.Get("credentialReadOnly").Get("okAccessPassphrase").String() | ||||||
| // 	isDemo := false | 	isDemo := false | ||||||
| // 	if core.Env == "demoEnv" { | 	if core.Env == "demoEnv" { | ||||||
| // 		isDemo = true | 		isDemo = true | ||||||
| // 	} | 	} | ||||||
| // 	rest.SetSimulate(isDemo).SetAPIKey(key, secure, pass) | 	rest.SetSimulate(isDemo).SetAPIKey(key, secure, pass) | ||||||
| // 	response, err := rest.Run(context.Background()) | 	response, err := rest.Run(context.Background()) | ||||||
| // 	if err != nil { | 	if err != nil { | ||||||
| // 		fmt.Println("restInvoke1 err:", subUrl, err) | 		fmt.Println("restInvoke1 err:", subUrl, err) | ||||||
| // 	} | 	} | ||||||
| // 	return response, err | 	return response, err | ||||||
| // } | } | ||||||
| 
 | 
 | ||||||
| // func (core *Core) RestInvoke2(subUrl string, method string, param *map[string]interface{}) (*rest.RESTAPIResult, error) { | // func (core *Core) RestInvoke2(subUrl string, method string, param *map[string]interface{}) (*rest.RESTAPIResult, error) { | ||||||
| // 	key, err1 := core.Cfg.Config.Get("credentialReadOnly").Get("okAccessKey").String() | // 	key, err1 := core.Cfg.Config.Get("credentialReadOnly").Get("okAccessKey").String() | ||||||
|  | |||||||
							
								
								
									
										21
									
								
								maX.go
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								maX.go
									
									
									
									
									
								
							| @ -71,6 +71,27 @@ func (mx MaX) SetToKey(cr *Core) ([]interface{}, error) { | |||||||
| 	return mx.Data, err | 	return mx.Data, err | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (mx *MaX) PushToWriteLogChan(cr *Core) error { | ||||||
|  | 	s := strconv.FormatFloat(float64(mx.Ts), 'f', 0, 64) | ||||||
|  | 	did := mx.InstID + mx.Period + s | ||||||
|  | 	mx0 := MaX{} | ||||||
|  | 	mx0.InstID = mx.InstID | ||||||
|  | 	mx0.Period = mx.Period | ||||||
|  | 	mx0.KeyName = mx.KeyName | ||||||
|  | 	mx0.Count = mx.Count | ||||||
|  | 	mx0.Ts = mx.Ts | ||||||
|  | 	mx0.AvgVal = mx.AvgVal | ||||||
|  | 	hs := HashString(did) | ||||||
|  | 	md, _ := json.Marshal(mx0) | ||||||
|  | 	wg := WriteLog{ | ||||||
|  | 		Content: md, | ||||||
|  | 		Tag:     "sardine.log.maX." + mx0.Period, | ||||||
|  | 		Id:      hs, | ||||||
|  | 	} | ||||||
|  | 	cr.WriteLogChan <- &wg | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // TODO | // TODO | ||||||
| // 返回: | // 返回: | ||||||
| // Sample:被顶出队列的元素 | // Sample:被顶出队列的元素 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zhangkun9038@dingtalk.com
						zhangkun9038@dingtalk.com