util

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS                       = 200
	SYSTEM_ERROR                  = 500
	INVALID_PARAMS                = 401
	INVALID_TOPIC_NAME            = 402
	INVALID_SERVICE_NAME          = 403
	MSG_NUM_LIMIT                 = 404
	MSG_NOT_EXIST                 = 405
	INCORRECT_ACCOUNT_OR_PASSWORD = 406
	DELAY_TIME_EXCEEDS_THE_LIMIT  = 501
)
View Source
const (
	WORKER_SERVICE           = "worker"
	CENTER_SERVICE           = "center"
	RECEIVE_SERVICE          = "receive"
	ADMIN_SERVICE            = "admin"
	ALL_SERVICE              = "all"
	WORKER_ADDRESS_CACHE_KEY = "workers"
	CENTER_ADDRESS_CACHE_KEY = "centers"
	KAFKA_TOPIC_PATH         = "/brokers/topics"
)

Variables

View Source
var RespMsg = map[int]string{
	200: "success",
	500: "system error",
	401: "invalid params",
	402: "topic name cannot be set [admin/center/worker/receive/lock/iptopic]",
	403: "service name can be only [admin/center/worker/receive/all]",
	404: "maximum num of messages is limit 500",
	405: "msg is not exist",
	406: "login failed, incorrect account or password",
	501: "the longest delay time is 7 days",
}

Functions

func Difference

func Difference(slice1, slice2 []string) []string

求差集 slice1-并集

func GetIPPos

func GetIPPos(workers []string, worker string) int

func GetLocalIp

func GetLocalIp() string

func GetWorkerIdByWorkerIp

func GetWorkerIdByWorkerIp(workerIp string) string

func GetWorkerIpByWorkerId

func GetWorkerIpByWorkerId(workerId string) string

func IPToWorkerFormat

func IPToWorkerFormat(IP string, port int64) string

func IPTopicNode

func IPTopicNode() string

func IPTopicsNode

func IPTopicsNode(ip string) string

zk IP节点存储关联的topic

func IPTopicsNodeWithPort

func IPTopicsNodeWithPort(ip string, port int64) string

zk IP节点存储关联的topic 带端口

func IPTopicsNodeWithPortV2

func IPTopicsNodeWithPortV2(ipPortStr string) string

func InetAtoN

func InetAtoN(ip string) int64

func InetNtoA

func InetNtoA(ip int64) string

func Intersect

func Intersect(slice1, slice2 []string) []string

求交集

func Ip2long

func Ip2long(ipstr string) uint32

func LockChildNode

func LockChildNode(childNodeName string) string

lock临时子节点

func LockNode

func LockNode() string

lock节点

func Long2ip

func Long2ip(ipLong uint32) string

func Md5V

func Md5V(str string) string

func OpenFile

func OpenFile(fileName string) *os.File

func ParseIntParam

func ParseIntParam(form url.Values, keys ...string) int

func ParseStringParam

func ParseStringParam(form url.Values, keys ...string) string

func RootNode

func RootNode() string

func ServiceRegisterChildNode

func ServiceRegisterChildNode(serviceName string, ip string, port int64) string

func ServiceRegisterChildNodeV2

func ServiceRegisterChildNodeV2(serviceName string, ipPortStr string) string

func ServiceRegisterNode

func ServiceRegisterNode(serviceName string) string

func TmpCenterNode

func TmpCenterNode() string

zk 临时center节点

func TmpReceiveNode

func TmpReceiveNode() string

zk 临时receive节点

func TmpWorkerNode

func TmpWorkerNode() string

zk 临时worker节点

func TopicCenterNode

func TopicCenterNode(ip string, port int64) string

center启动时注册的临界时节点

func TopicNode

func TopicNode(topic string) string

topic节点名字

func TopicWorkerNode

func TopicWorkerNode(ip string, port int64) string

worker启动时注册的临界时节点

func TopicWorkerNodeV2

func TopicWorkerNodeV2(ipPortStr string) string

func Union

func Union(slice1, slice2 []string) []string

求并集

func Wait

func Wait() os.Signal

func WorkerIPPortFormat

func WorkerIPPortFormat(workers []string, port int64) []string

Types

type Client

type Client struct {
	*http.Client
}

func NewClient

func NewClient(c *http.Client) *Client

func (*Client) DoAsJson

func (c *Client) DoAsJson(req *http.Request, v interface{}) error

type Response

type Response struct {
	Ec     int         `json:"ec"`
	Em     string      `json:"em"`
	Result interface{} `json:"result"`
}

func RespJson

func RespJson(errno int, result interface{}) *Response

Jump to

Keyboard shortcuts

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