helper

package
v0.0.0-...-6c75c7c Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileName      = "data"
	ConfigProvider      = "consul"
	ConfigPathFmt       = "/config/%s/%s"
	ConfigFmtYaml       = "yaml"
	ConfigFmtJson       = "json"
	ConfigWatchInterval = 1 * time.Second
)
View Source
const (
	ConsulDeRegisterCriticalServiceAfter = "10m"
	ConsulInterval                       = "15s"
	ConsulTTL                            = "10s"
	ConsulDefaultSchema                  = "http://"
)
View Source
const (
	// system level
	AppName = "appname"
	AppPort = "httpport"
	// ca relative
	KeyType   = "keyType"
	CertType  = "certType"
	KeyStart  = "-----BEGIN RSA PRIVATE KEY-----"
	KeyEnd    = "-----END RSA PRIVATE KEY-----"
	CertStart = "-----BEGIN CERTIFICATE-----"
	CertEnd   = "-----END CERTIFICATE-----"
	// config path
	ConfPath = "./conf/app.conf"
)
View Source
const (
	EventPathFmt = "event/%s/%s"
)
View Source
const (
	LeaderElectionPathFmt = "lock/%s/leader"
)
View Source
const (
	SlangerEventTypeOperationStatus = "operationStatus"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BeegoConfig

type BeegoConfig struct {
	AppName  string `ini:"appname"`
	HttpPort string `ini:"httpport"`
	RunMode  string `ini:"runmode"`
}

type ConfDelta

type ConfDelta struct {
	OData interface{}
	NData interface{}
}

///////////////////////////////// config file ////////////////////////////////

type Config

type Config struct {
	FileName string
	Format   string
	Data     interface{}
	// contains filtered or unexported fields
}

func GetConfInst

func GetConfInst(data ...interface{}) *Config

func (*Config) DeRegister

func (c *Config) DeRegister(name string)

func (*Config) LoadConf

func (c *Config) LoadConf() interface{}

func (*Config) Register

func (c *Config) Register(name string, f func(confDelta *ConfDelta))

func (*Config) Run

func (c *Config) Run()

type Consul

type Consul struct {
	// contains filtered or unexported fields
}

func (*Consul) CheckKey

func (c *Consul) CheckKey(key string, opts *stdConsul.QueryOptions) bool

func (*Consul) DeleteKey

func (c *Consul) DeleteKey(key string) error

func (*Consul) GetConsulClient

func (c *Consul) GetConsulClient() *stdConsul.Client

func (*Consul) GetGoKitConsulClient

func (c *Consul) GetGoKitConsulClient() goKitConsul.Client

func (*Consul) GetKey

func (c *Consul) GetKey(key string) (string, error)

func (*Consul) Health

func (c *Consul) Health() bool

func (Consul) New

func (c Consul) New() *Consul

func (*Consul) RegistryService

func (c *Consul) RegistryService(service, port, healthCheckURL string) error

func (*Consul) SetKey

func (c *Consul) SetKey(key, value string) error

func (*Consul) WatchKey

func (c *Consul) WatchKey(key string, stop chan bool) <-chan *WatchResp

type Consumer

type Consumer struct {
	Group       string
	Topic       string
	URL         string
	ClusterId   string
	ClientId    string
	DurableName string
	CallBack    func(*stan.Msg)
	NConn       *nats.Conn
	SConn       stan.Conn
	// contains filtered or unexported fields
}

func (*Consumer) Close

func (c *Consumer) Close()

func (*Consumer) Run

func (c *Consumer) Run() error

func (*Consumer) RunWithSubscribe

func (c *Consumer) RunWithSubscribe() error

func (*Consumer) Shutdown

func (c *Consumer) Shutdown()

type EndpointMap

type EndpointMap struct {
	// contains filtered or unexported fields
}

endpoint map

func GetEndpointMap

func GetEndpointMap() *EndpointMap

type EnvVar

type EnvVar struct {
	ConsulAddr string
	ConsulPort string
}

func (EnvVar) GetConsulAddr

func (e EnvVar) GetConsulAddr() string

func (EnvVar) GetConsulPort

func (e EnvVar) GetConsulPort() string

func (EnvVar) GetConsulURI

func (e EnvVar) GetConsulURI() string

type Event

type Event struct {
	Name     string
	Callback func([]byte)
	// contains filtered or unexported fields
}

func (*Event) Broadcast

func (e *Event) Broadcast(value string) error

type EventMap

type EventMap struct {
	// contains filtered or unexported fields
}

func GetEventMap

func GetEventMap() *EventMap

func (*EventMap) DeRegistry

func (m *EventMap) DeRegistry(key string) error

func (*EventMap) Get

func (m *EventMap) Get(key string) *Event

func (*EventMap) Registry

func (m *EventMap) Registry(e *Event) error

type HealthCheck

type HealthCheck struct {
}

func (*HealthCheck) Check

func (h *HealthCheck) Check() error

type HttpClient

type HttpClient struct {
	Service string
}

func (HttpClient) Delete

func (c HttpClient) Delete(respObj interface{}, url string, urlParams []string) error

func (HttpClient) Execute

func (c HttpClient) Execute(reqObj interface{}, respObj interface{}, method, url string, header map[string]string, urlParams []string) error

func (HttpClient) Get

func (c HttpClient) Get(respObj interface{}, url string, urlParams []string) error

func (HttpClient) GetWithHeader

func (c HttpClient) GetWithHeader(respObj interface{}, url string, header map[string]string, urlParams []string) error

func (HttpClient) Post

func (c HttpClient) Post(reqObj interface{}, respObj interface{}, url string, urlParams []string) error

func (HttpClient) PostWithHeader

func (c HttpClient) PostWithHeader(reqObj interface{}, respObj interface{}, header map[string]string, url string, urlParams []string) error

func (HttpClient) Put

func (c HttpClient) Put(reqObj interface{}, respObj interface{}, url string, urlParams []string) error

func (HttpClient) PutWithHeader

func (c HttpClient) PutWithHeader(reqObj interface{}, respObj interface{}, header map[string]string, url string, urlParams []string) error

type LeaderElection

type LeaderElection struct {
	Consul   *Consul
	TTL      time.Duration
	Callback func(leader bool)
	// contains filtered or unexported fields
}

func (*LeaderElection) Run

func (l *LeaderElection) Run()

type NATSConsumer

type NATSConsumer struct {
	Group    string // no used for NATS
	Topic    string
	URL      string
	CallBack func(*nats.Msg)
	Conn     *nats.Conn
}

func (*NATSConsumer) Run

func (c *NATSConsumer) Run() error

func (*NATSConsumer) Shutdown

func (c *NATSConsumer) Shutdown()

type NATSProducer

type NATSProducer struct {
	Group string // no used for NATS
	URL   string
	Conn  *nats.Conn
}

func (*NATSProducer) Send

func (p *NATSProducer) Send(topic string, body []byte) error

func (*NATSProducer) Shutdown

func (p *NATSProducer) Shutdown()

func (*NATSProducer) Start

func (p *NATSProducer) Start() error

type PageRequest

type PageRequest struct {
	CurrentPage int `json:"currentPage"`
	PageSize    int `json:"pageSize"`
}

page begin from 1

type Paginator

type Paginator struct {
	*PageRequest
	TotalPages    int         `json:"totalPages"`
	TotalElements int         `json:"totalElements"`
	Content       interface{} `json:"content"`
}

page search util

func (Paginator) GetOffset

func (p Paginator) GetOffset(r *PageRequest) int

func (Paginator) GetTotalPages

func (p Paginator) GetTotalPages(r *PageRequest, totalElements int) int

type Producer

type Producer struct {
	Group     string // no used for NATS
	URL       string
	ClusterId string
	ClientId  string
	NConn     *nats.Conn
	SConn     stan.Conn
}

func (*Producer) Send

func (p *Producer) Send(topic string, body []byte) error

func (*Producer) SendAsync

func (p *Producer) SendAsync(topic string, body []byte) error

func (*Producer) Shutdown

func (p *Producer) Shutdown()

func (*Producer) Start

func (p *Producer) Start() error

type RocketMqConsumer

type RocketMqConsumer struct {
	Group      string
	Topic      string
	NameServer string
	CallBack   func([]*rocketmq.MessageExt) error
	// contains filtered or unexported fields
}

func (*RocketMqConsumer) Run

func (c *RocketMqConsumer) Run() error

func (*RocketMqConsumer) Shutdown

func (c *RocketMqConsumer) Shutdown()

type RocketMqProducer

type RocketMqProducer struct {
	Group      string
	NameServer string
	// contains filtered or unexported fields
}

func (*RocketMqProducer) Send

func (p *RocketMqProducer) Send(topic string, body []byte) error

func (*RocketMqProducer) Shutdown

func (p *RocketMqProducer) Shutdown()

func (*RocketMqProducer) Start

func (p *RocketMqProducer) Start() error

type Role

type Role struct {
	// contains filtered or unexported fields
}

func GetRoleInst

func GetRoleInst() *Role

func (*Role) IsLeader

func (r *Role) IsLeader() bool

func (*Role) SetRole

func (r *Role) SetRole(isLeader bool)

type Utils

type Utils struct {
}

func (Utils) Decode

func (u Utils) Decode(data, keyType string) (result string, err error)

func (Utils) GetAppName

func (u Utils) GetAppName() string

func (Utils) GetAppPort

func (u Utils) GetAppPort() string

func (Utils) GetMyIPAddr

func (u Utils) GetMyIPAddr() string

func (Utils) GetMyIdentity

func (u Utils) GetMyIdentity() string

func (Utils) GetRunMode

func (u Utils) GetRunMode() string

func (Utils) GetType

func (u Utils) GetType(v interface{}) (ty reflect.Type)

func (Utils) NatsHealth

func (u Utils) NatsHealth(url string) error

func (Utils) ObjectName

func (u Utils) ObjectName(v interface{}) (name string)

func (Utils) ObjectNameAppend

func (u Utils) ObjectNameAppend(v interface{}, append string) string

func (Utils) ReadConfig

func (u Utils) ReadConfig(path string) (BeegoConfig, error)

func (Utils) SystemHealth

func (u Utils) SystemHealth() error

type WatchResp

type WatchResp struct {
	Value []byte
	Error error
}

type WsServer

type WsServer struct {
	AppId  string
	Key    string
	Secret string
	Host   string
	// contains filtered or unexported fields
}

func (*WsServer) GetClient

func (ws *WsServer) GetClient()

func (*WsServer) PushMsgToUI

func (ws *WsServer) PushMsgToUI(channel string, eventName string, data interface{})

func (*WsServer) PushOperationStatusToUI

func (ws *WsServer) PushOperationStatusToUI(channels []string, data interface{})

Jump to

Keyboard shortcuts

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