Skip to content

Commit

Permalink
Update to Iris version 12
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Nov 7, 2019
1 parent 00444dd commit 4118b35
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 222 deletions.
2 changes: 1 addition & 1 deletion go.mod
@@ -1,3 +1,3 @@
module github.com/peterq/pan-light

go 1.12
go 1.13
8 changes: 4 additions & 4 deletions qt/tool-chain/binding/parser/class_fix.go
Expand Up @@ -182,16 +182,16 @@ func (c *Class) fixLinkage() {
case "QtCore":
{
c.WeakLink = map[string]struct{}{
"QtGui": struct{}{},
"QtWidgets": struct{}{},
"QtGui": {},
"QtWidgets": {},
}
}

case "QtGui":
{
c.WeakLink = map[string]struct{}{
"QtWidgets": struct{}{},
"QtMultimedia": struct{}{},
"QtWidgets": {},
"QtMultimedia": {},
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion qt/tool-chain/cmd/moc/moc.go
Expand Up @@ -227,7 +227,7 @@ func moc(path, target, tags string, fast, slow, root bool, l int, dirty bool) {

//copy properties + signals + slots
utils.Log.Debug("start copy properties + signals + slots")
for _ = range append(m.Namespace.Classes, otherclasses...) {
for range append(m.Namespace.Classes, otherclasses...) {
for _, c := range append(m.Namespace.Classes, otherclasses...) {
bc, ok := parser.State.ClassMap[c.Bases]
if !ok || bc.Pkg == "" {
Expand Down
36 changes: 18 additions & 18 deletions qt/tool-chain/cmd/setup/test.go
Expand Up @@ -49,26 +49,26 @@ func Test(target string, docker, vagrant bool, vagrantsystem string) {
if utils.CI() {
mode = "build"
examples = map[string][]string{
"androidextras": []string{"jni", "notification"},
"androidextras": {"jni", "notification"},

"canvas3d": []string{"framebuffer", "interaction", "jsonmodels",
"canvas3d": {"framebuffer", "interaction", "jsonmodels",
"quickitemtexture", "textureandlight",
filepath.Join("threejs", "cellphone"),
filepath.Join("threejs", "oneqt"),
filepath.Join("threejs", "planets"),
},

"charts": []string{"audio"},
"charts": {"audio"},

"common": []string{"qml_demo", "widgets_demo"},
"common": {"qml_demo", "widgets_demo"},

//"grpc": []string{"hello_world","hello_world2"},

//"gui": []string{"analogclock", "openglwindow", "rasterwindow"},

//opengl: []string{"2dpainting"},

"qml": []string{"adding", "application", "drawer_nav_x",
"qml": {"adding", "application", "drawer_nav_x",
filepath.Join("extending", "chapter1-basics"),
filepath.Join("extending", "chapter2-methods"),
filepath.Join("extending", "chapter3-bindings"),
Expand All @@ -84,39 +84,39 @@ func Test(target string, docker, vagrant bool, vagrantsystem string) {
//filepath.Join("printslides", "cmd", "printslides"),
"prop", "prop2" /*"quickflux", "webview"*/},

"qt3d": []string{"audio-visualizer-qml"},
"qt3d": {"audio-visualizer-qml"},

"quick": []string{"bridge", "bridge2", "calc", "dialog", "dynamic",
"quick": {"bridge", "bridge2", "calc", "dialog", "dynamic",
"hotreload", "listview", "sailfish", "tableview", "translate", "view"},

"sailfish": []string{"listview", "listview_variant"},
"sailfish": {"listview", "listview_variant"},

"showcases": []string{"sia"},
"showcases": {"sia"},

"sql": []string{"masterdetail", "masterdetail_qml", "querymodel"},
"sql": {"masterdetail", "masterdetail_qml", "querymodel"},

"uitools": []string{"calculator"},
"uitools": {"calculator"},

"webchannel": []string{"chatserver-go" /*"standalone" "webview"*/},
"webchannel": {"chatserver-go" /*"standalone" "webview"*/},

"widgets": []string{"bridge2" /*"dropsite"*/, "graphicsscene", "line_edits", "pixel_editor",
"widgets": {"bridge2" /*"dropsite"*/, "graphicsscene", "line_edits", "pixel_editor",
/*"renderer"*/ "share", "systray" /*"table"*/, "textedit", filepath.Join("treeview", "treeview_dual"),
filepath.Join("treeview", "treeview_filelist"), "video_player" /*"webengine"*/, "xkcd"},
}
} else {
if strings.HasPrefix(target, "sailfish") {
examples = map[string][]string{
"quick": []string{"sailfish"},
"quick": {"sailfish"},

"sailfish": []string{"listview", "listview_variant"},
"sailfish": {"listview", "listview_variant"},
}
} else {
examples = map[string][]string{
"qml": []string{"application", "drawer_nav_x", "gallery"},
"qml": {"application", "drawer_nav_x", "gallery"},

"quick": []string{"calc"},
"quick": {"calc"},

"widgets": []string{"line_edits", "pixel_editor", "textedit"},
"widgets": {"line_edits", "pixel_editor", "textedit"},
}
}
}
Expand Down
19 changes: 9 additions & 10 deletions server/artisan/web.go
Expand Up @@ -3,8 +3,7 @@ package artisan
import (
"errors"
"fmt"
"github.com/kataras/iris"
"github.com/kataras/iris/context"
"github.com/kataras/iris/v12"
"github.com/peterq/pan-light/server/artisan/cache"
"github.com/peterq/pan-light/server/conf"
"github.com/peterq/pan-light/server/pc-api/middleware"
Expand All @@ -13,9 +12,9 @@ import (
"time"
)

func ApiHandler(handler func(ctx context.Context, param JsonMap) (result interface{}, err error)) func(ctx context.Context) {
func ApiHandler(handler func(ctx iris.Context, param JsonMap) (result interface{}, err error)) func(ctx iris.Context) {

return func(ctx context.Context) {
return func(ctx iris.Context) {
var param JsonMap
var result interface{}

Expand All @@ -41,7 +40,7 @@ func ApiHandler(handler func(ctx context.Context, param JsonMap) (result interfa
}
}

func ApiRecover(ctx context.Context) {
func ApiRecover(ctx iris.Context) {
defer func() {
e := recover()
if e != nil {
Expand Down Expand Up @@ -78,15 +77,15 @@ func ApiRecover(ctx context.Context) {
type ThrottleOption struct {
Duration time.Duration // 时间窗口
Number int // 允许操作次数
GetKey func(ctx context.Context) string
GetKey func(ctx iris.Context) string
}

type throttleState struct {
Time int64 `json:"time"`
Water float64 `json:"water"`
}

func (o ThrottleOption) hit(ctx context.Context) time.Duration {
func (o ThrottleOption) hit(ctx iris.Context) time.Duration {
key := o.GetKey(ctx)
stateKey := "throttle-" + key

Expand All @@ -113,10 +112,10 @@ func (o ThrottleOption) hit(ctx context.Context) time.Duration {
}

// 频率限制器, 漏斗算法
func Throttle(options ...ThrottleOption) func(ctx context.Context) {
func Throttle(options ...ThrottleOption) func(ctx iris.Context) {
for i, option := range options {
if option.GetKey == nil {
options[i].GetKey = func(ctx context.Context) string {
options[i].GetKey = func(ctx iris.Context) string {
return strings.Join([]string{
ctx.GetCurrentRoute().Name(),
middleware.ContextLoginInfo(ctx).Uk(),
Expand All @@ -126,7 +125,7 @@ func Throttle(options ...ThrottleOption) func(ctx context.Context) {
}
}
}
return func(ctx context.Context) {
return func(ctx iris.Context) {
if conf.Conf.Debug {
ctx.Next()
return
Expand Down
2 changes: 1 addition & 1 deletion server/conf/conf.go
Expand Up @@ -2,7 +2,7 @@ package conf

import (
"github.com/go-redis/redis"
"github.com/kataras/iris"
"github.com/kataras/iris/v12"
"gopkg.in/mgo.v2"
"os"
"strings"
Expand Down
5 changes: 2 additions & 3 deletions server/demo/demo-init.go
@@ -1,14 +1,13 @@
package demo

import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
"github.com/kataras/iris/v12"
"github.com/peterq/pan-light/server/demo/rpc"
)

func Init(router iris.Party, conf map[interface{}]interface{}) {
// 静态页
router.Get("/", func(context context.Context) {
router.Get("/", func(context iris.Context) {
context.Redirect("/demo/init.html")
})
hosts := map[string]string{}
Expand Down
5 changes: 3 additions & 2 deletions server/demo/rpc/host-handler.go
@@ -1,9 +1,10 @@
package rpc

import (
"github.com/kataras/iris/core/errors"
"github.com/peterq/pan-light/server/realtime"
"errors"
"strings"

"github.com/peterq/pan-light/server/realtime"
)

var hostRpcMap = map[string]realtime.RpcHandler{
Expand Down
2 changes: 1 addition & 1 deletion server/demo/rpc/rpc-init.go
Expand Up @@ -2,7 +2,7 @@ package rpc

import (
"fmt"
"github.com/kataras/iris"
"github.com/kataras/iris/v12"
"github.com/peterq/pan-light/server/demo/nickname"
"github.com/peterq/pan-light/server/realtime"
"github.com/pkg/errors"
Expand Down
30 changes: 10 additions & 20 deletions server/go.mod
@@ -1,26 +1,16 @@
module github.com/peterq/pan-light/server

go 1.13

// replace github.com/peterq/pan-light => ../

require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-redis/cache v6.4.0+incompatible
github.com/go-redis/redis v6.15.2+incompatible
github.com/iris-contrib/middleware v0.0.0-20181021162728-8bd5d51b3c2e
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect
github.com/juju/testing v0.0.0-20190429233213-dfc56b8c09fc // indirect
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/kataras/iris v11.1.1+incompatible
github.com/kr/pretty v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/pkg/errors v0.8.0
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
golang.org/x/net v0.0.0-20190311183353-d8887717615a
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed // indirect
google.golang.org/appengine v1.6.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce
github.com/go-redis/redis v6.15.6+incompatible
github.com/iris-contrib/middleware/jwt v0.0.0-20191028172159-41f72a73786a
github.com/kataras/iris/v12 v12.0.1
github.com/pkg/errors v0.8.1
golang.org/x/net v0.0.0-20191105084925-a882066a44e0
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
)

// replace github.com/peterq/pan-light => ../

0 comments on commit 4118b35

Please sign in to comment.