Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["notify.go"],
importpath = "go-common/app/infra/notify/model",
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,93 @@
package model
import (
"net/url"
"time"
)
// Watcher define watcher object.
type Watcher struct {
ID int64
Cluster string
Topic string
Group string
Offset string
Callback string
Callbacks []*Callback
Filter bool
Filters []*Filter
Concurrent int // concurrent goroutine for sub.
Mtime time.Time
}
// Pub define pub.
type Pub struct {
ID int64
Cluster string
Topic string
Group string
Operation int8
AppSecret string
}
// Callback define callback event
type Callback struct {
URL *NotifyURL
Priority int8
Finished bool
}
// NotifyURL callback url with parsed info
type NotifyURL struct {
RawURL string
Schema string
Host string
Path string
Query url.Values
}
// filter condition
const (
ConditionEq = 0
ConditionPre = 1
)
// Filter define filter object.
type Filter struct {
Field string
Condition int8 // 0 :eq 1:neq
Value string
}
// Message define canal message.
type Message struct {
Table string `json:"table,omitempty"`
Action string `json:"action,omitempty"`
}
// ArgPub pub arg.
type ArgPub struct {
AppKey string `form:"appkey" validate:"min=1"`
AppSecret string `form:"appsecret" validate:"min=1"`
Group string `form:"group" validate:"min=1"`
Topic string `form:"topic" validate:"min=1"`
Key string `form:"key" validate:"min=1"`
Msg string `form:"msg" validate:"min=1"`
}
// FailBackup fail backup msg.
type FailBackup struct {
ID int64
Cluster string
Topic string
Group string
Offset int64
Msg string
Index int64
}
// Notify callback schema
const (
LiverpcSchema = "liverpc"
HTTPSchema = "http"
)