Browse Source

修复合并冲突

gitlink
Sydonian 1 year ago
parent
commit
ff85feb9fe
4 changed files with 12 additions and 115 deletions
  1. +1
    -1
      pkgs/ioswitch/exec/driver.go
  2. +1
    -1
      pkgs/ioswitch/exec/worker.go
  3. +10
    -9
      sdks/scheduler/modeljob.go
  4. +0
    -104
      utils/time2/test.go

+ 1
- 1
pkgs/ioswitch/exec/driver.go View File

@@ -45,7 +45,7 @@ func (e *Driver) Signal(signal *DriverSignalVar) {
}

func (e *Driver) Wait(ctx context.Context) (map[string]any, error) {
stored, err := e.callback.WaitValue(ctx)
stored, err := e.callback.Wait(ctx)
if err != nil {
return nil, err
}


+ 1
- 1
pkgs/ioswitch/exec/worker.go View File

@@ -75,7 +75,7 @@ func (s *Worker) FindByIDContexted(ctx context.Context, id PlanID) *Executor {

s.lock.Unlock()

sw, _ = cb.WaitValue(ctx)
sw, _ = cb.Wait(ctx)

s.lock.Lock()
defer s.lock.Unlock()


+ 10
- 9
sdks/scheduler/modeljob.go View File

@@ -2,12 +2,13 @@ package schsdk

import (
"fmt"
"net/url"
"strings"

"gitlink.org.cn/cloudream/common/consts/errorcode"
"gitlink.org.cn/cloudream/common/pkgs/mq"
myhttp "gitlink.org.cn/cloudream/common/utils/http"
"gitlink.org.cn/cloudream/common/utils/http2"
"gitlink.org.cn/cloudream/common/utils/serder"
"net/url"
"strings"
)

// 这个结构体无任何字段,但实现了Noop,每种MessageBody都要内嵌这个结构体
@@ -112,7 +113,7 @@ func (c *Client) QueryRunningModels(req QueryRunningModelsReq) (*RunningModelRes
return nil, err
}

resp, err := myhttp.GetJSON(url, myhttp.RequestParam{
resp, err := http2.GetJSON(url, http2.RequestParam{
Body: req,
})
if err != nil {
@@ -120,7 +121,7 @@ func (c *Client) QueryRunningModels(req QueryRunningModelsReq) (*RunningModelRes
}

contType := resp.Header.Get("Content-Type")
if strings.Contains(contType, myhttp.ContentTypeJSON) {
if strings.Contains(contType, http2.ContentTypeJSON) {
var codeResp response[RunningModelResp]
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil {
return nil, fmt.Errorf("parsing response: %w", err)
@@ -142,7 +143,7 @@ func (c *Client) QueryAllModels(req QueryRunningModelsReq) (*AllModelResp, error
return nil, err
}

resp, err := myhttp.GetJSON(url, myhttp.RequestParam{
resp, err := http2.GetJSON(url, http2.RequestParam{
Body: req,
})
if err != nil {
@@ -150,7 +151,7 @@ func (c *Client) QueryAllModels(req QueryRunningModelsReq) (*AllModelResp, error
}

contType := resp.Header.Get("Content-Type")
if strings.Contains(contType, myhttp.ContentTypeJSON) {
if strings.Contains(contType, http2.ContentTypeJSON) {
var codeResp response[AllModelResp]
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil {
return nil, fmt.Errorf("parsing response: %w", err)
@@ -172,7 +173,7 @@ func (c *Client) ECSNodeRunningInfo(req ECSNodeRunningInfoReq) (*ECSNodeRunningI
return nil, err
}

resp, err := myhttp.GetJSON(url, myhttp.RequestParam{
resp, err := http2.GetJSON(url, http2.RequestParam{
Body: req,
})
if err != nil {
@@ -180,7 +181,7 @@ func (c *Client) ECSNodeRunningInfo(req ECSNodeRunningInfoReq) (*ECSNodeRunningI
}

contType := resp.Header.Get("Content-Type")
if strings.Contains(contType, myhttp.ContentTypeJSON) {
if strings.Contains(contType, http2.ContentTypeJSON) {
var codeResp response[ECSNodeRunningInfoResp]
if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil {
return nil, fmt.Errorf("parsing response: %w", err)


+ 0
- 104
utils/time2/test.go View File

@@ -1,104 +0,0 @@
package time2

import (
"fmt"
"path"
"runtime"
"strings"
"time"
)

type Measurement struct {
startTime time.Time
lastPointTime time.Time
printer func(string)
on bool
title string
}

func NewMeasurement(printer func(string)) Measurement {
return Measurement{
printer: printer,
}
}

func (m *Measurement) Begin(on bool, title ...string) {
if m == nil {
return
}

m.on = on
m.title = strings.Join(title, ".")

if on {
m.startTime = time.Now()
m.lastPointTime = m.startTime

_, file, line, ok := runtime.Caller(1)

titlePart := ""
if m.title != "" {
titlePart = fmt.Sprintf(":%s", m.title)
}

if ok {
m.printer(fmt.Sprintf("[begin%v]%v:%v", titlePart, path.Base(file), line))
} else {
m.printer(fmt.Sprintf("[begin%v]unknown point", titlePart))
}
}
}

func (m *Measurement) Point(head ...string) {
if m == nil {
return
}

if m.on {
m.printer(m.makePointString(strings.Join(head, ".")))
}
}

func (m *Measurement) makePointString(head string) string {
last := m.lastPointTime
now := time.Now()
m.lastPointTime = now

_, file, line, ok := runtime.Caller(2)

prefixCont := ""

if m.title != "" {
prefixCont = m.title
}

if head != "" {
if prefixCont == "" {
prefixCont = head
} else {
prefixCont = fmt.Sprintf("%s.%s", prefixCont, head)
}
}

prefixPart := ""
if prefixCont != "" {
prefixPart = fmt.Sprintf("[%s]", prefixCont)
}

if ok {
return fmt.Sprintf("%v%v:%v@%v(%v)", prefixPart, path.Base(file), line, now.Sub(last), now.Sub(m.startTime))
}

return fmt.Sprintf("%vunknown point@%v(%v)", prefixPart, now.Sub(last), now.Sub(m.startTime))
}

func (m *Measurement) End(head ...string) {
if m == nil {
return
}

if m.on {
m.printer(fmt.Sprintf("[end]%v\n", m.makePointString(strings.Join(head, "."))))
}
}


Loading…
Cancel
Save