Documentation ¶
Index ¶
- Constants
- Variables
- type APIClientConfiguration
- type APIResponse
- type App
- type CallResult
- type ConsumeFn
- type DBClient
- type DBConfiguration
- type DBModel
- func (m *DBModel) Aggregate(pipeline interface{}, result interface{}) error
- func (m *DBModel) Count(query interface{}) *DbResponse
- func (m *DBModel) Create(entity interface{}) *DbResponse
- func (m *DBModel) CreateIndex(index mgo.Index) error
- func (m *DBModel) CreateMany(entityList ...interface{}) *DbResponse
- func (m *DBModel) Delete(selector interface{}) *DbResponse
- func (m *DBModel) GetColWith(s *DBSession) (*mgo.Collection, error)
- func (m *DBModel) GetFreshSession() *DBSession
- func (m *DBModel) IncreOne(query interface{}, fieldName string, value int) *DbResponse
- func (m *DBModel) Init(s *DBSession) error
- func (m *DBModel) NewList(limit int) interface{}
- func (m *DBModel) NewObject() interface{}
- func (m *DBModel) Query(query interface{}, offset int, limit int, reverse bool) *DbResponse
- func (m *DBModel) QueryOne(query interface{}) *DbResponse
- func (m *DBModel) QueryS(query interface{}, offset int, limit int, sortStr string) *DbResponse
- func (m *DBModel) Update(query interface{}, updater interface{}) *DbResponse
- func (m *DBModel) UpdateOne(query interface{}, updater interface{}) *DbResponse
- func (m *DBModel) UpsertOne(query interface{}, updater interface{}) *DbResponse
- type DBQueue2
- func (dbq *DBQueue2) Init(mSession *DBSession, dbName string)
- func (dbq *DBQueue2) InitWithExpiredTime(mSession *DBSession, dbName string, expiredTime time.Duration)
- func (dbq *DBQueue2) Push(data interface{}) error
- func (dbq *DBQueue2) PushWithKey(data interface{}, keys *[]string) error
- func (dbq *DBQueue2) StartConsumer(consumer ConsumeFn, channelNum int)
- type DBQueueChannel
- type DBQueueConnector
- type DBSession
- type DbResponse
- type DbStatusEnum
- type Error
- type HTTPMethod
- type HTTPMethodEnum
- type HandleFunc
- type IPoll
- type KQueue
- type LCache
- type MethodEnum
- type MethodValue
- type OnConnectedHandler
- type OutboundAPIRequest
- func (req *OutboundAPIRequest) GetContent(data interface{}) error
- func (req *OutboundAPIRequest) GetContentText() string
- func (req *OutboundAPIRequest) GetHeaders() map[string]string
- func (req *OutboundAPIRequest) GetIP() string
- func (req *OutboundAPIRequest) GetMethod() *MethodValue
- func (req *OutboundAPIRequest) GetParams() map[string]string
- func (req *OutboundAPIRequest) GetPath() string
- type QueueItem
- type Request
- type RequestLogEntry
- type Response
- type RestClient
- func (c *RestClient) MakeHTTPRequest(method HTTPMethod, headers map[string]string, params map[string]string, ...) (*RestResult, error)
- func (c *RestClient) MakeHTTPRequestWithKey(method HTTPMethod, headers map[string]string, params map[string]string, ...) (*RestResult, error)
- func (c *RestClient) MakeRequest(req OutboundAPIRequest) *APIResponse
- func (c *RestClient) SetDBLog(dbName string, session *DBSession)
- func (c *RestClient) SetDebug(val bool)
- func (c *RestClient) SetLoggerName(loggerName string)
- func (c *RestClient) SetMaxRetryTime(maxRetryTime int)
- func (c *RestClient) SetTimeout(timeout time.Duration)
- func (c *RestClient) SetWaitTime(waitTime time.Duration)
- type RestResult
- type Server
- type StatusEnum
- type Task
- type Worker
Constants ¶
const None = "NONE"
Variables ¶
var APIMethod = MethodEnum{ GET: &MethodValue{Value: "GET"}, POST: &MethodValue{Value: "POST"}, PUT: &MethodValue{Value: "PUT"}, DELETE: &MethodValue{Value: "DELETE"}, OPTIONS: &MethodValue{Value: "OPTIONS"}, }
APIMethod Published enum
var APIStatus = &StatusEnum{
Ok: "OK",
Error: "ERROR",
Invalid: "INVALID",
NotFound: "NOT_FOUND",
Forbidden: "FORBIDDEN",
Existed: "EXISTED",
Unauthorized: "UNAUTHORIZED",
}
APIStatus Published enum
var DbStatus = &DbStatusEnum{
Ok: "OK",
Error: "ERROR",
NotFound: "NOT_FOUND",
}
var HTTPMethods = &HTTPMethodEnum{
Get: "GET",
Post: "POST",
Put: "PUT",
Head: "HEAD",
Delete: "DELETE",
Option: "OPTION",
}
HTTPMethods Supported HTTP Method
Functions ¶
This section is empty.
Types ¶
type APIClientConfiguration ¶
type APIClientConfiguration struct { Address string Protocol string Timeout time.Duration MaxRetry int WaitToRetry time.Duration LoggingCol string MaxConnection int }
APIClientConfiguration
type APIResponse ¶
type App ¶ added in v0.0.2
type App struct { Name string Server *Server DBList []*DBClient WorkerList []*Worker // contains filtered or unexported fields }
App ..
func (*App) OnAllDBConnected ¶ added in v0.0.2
SetupDBClient ...
func (*App) SetupAPIServer ¶ added in v0.0.2
SetupAPIServer ...
func (*App) SetupDBClient ¶ added in v0.0.2
func (app *App) SetupDBClient(config DBConfiguration) *DBClient
SetupDBClient ...
type CallResult ¶
type CallResult struct { RespCode int `json:"respCode,omitempty" bson:"resp_code,omitempty"` RespHeader map[string][]string `json:"respHeader,omitempty" bson:"resp_header,omitempty"` RespBody *string `json:"respBody,omitempty" bson:"resp_body,omitempty"` ResponseTime int64 `json:"responseTime,omitempty" bson:"response_time,omitempty"` ErrorLog *string `json:"errorLog,omitempty" bson:"error_log,omitempty"` }
CallResult ...
type DBClient ¶
type DBClient struct { Name string Config DBConfiguration // contains filtered or unexported fields }
DBClient ..
func (*DBClient) OnConnected ¶
func (client *DBClient) OnConnected(fn OnConnectedHandler)
OnConnected ...
type DBConfiguration ¶
type DBConfiguration struct { Address []string Ssl bool Username string Password string AuthDB string ReplicaSetName string SecondaryPreferred bool }
DBConfiguration ...
type DBModel ¶
type DBModel struct { ColName string DBName string TemplateObject interface{} // contains filtered or unexported fields }
DBModel ...
func (*DBModel) Count ¶
func (m *DBModel) Count(query interface{}) *DbResponse
Count Count object which matched with query.
func (*DBModel) Create ¶
func (m *DBModel) Create(entity interface{}) *DbResponse
Create insert one object into DB
func (*DBModel) CreateMany ¶
func (m *DBModel) CreateMany(entityList ...interface{}) *DbResponse
CreateMany insert many object into db
func (*DBModel) Delete ¶
func (m *DBModel) Delete(selector interface{}) *DbResponse
Delete Delete all object which matched with selector
func (*DBModel) GetColWith ¶
func (m *DBModel) GetColWith(s *DBSession) (*mgo.Collection, error)
GetColWith ...
func (*DBModel) GetFreshSession ¶
GetFreshSession ...
func (*DBModel) IncreOne ¶
func (m *DBModel) IncreOne(query interface{}, fieldName string, value int) *DbResponse
IncreOne Increase one field of the document & return new value
func (*DBModel) NewObject ¶
func (m *DBModel) NewObject() interface{}
NewObject return new object with same type of TemplateObject
func (*DBModel) Query ¶
func (m *DBModel) Query(query interface{}, offset int, limit int, reverse bool) *DbResponse
Query Get all object in DB
func (*DBModel) QueryS ¶
func (m *DBModel) QueryS(query interface{}, offset int, limit int, sortStr string) *DbResponse
QueryS Get all object in DB with orderby clause
func (*DBModel) Update ¶
func (m *DBModel) Update(query interface{}, updater interface{}) *DbResponse
Update Update all matched item
func (*DBModel) UpdateOne ¶
func (m *DBModel) UpdateOne(query interface{}, updater interface{}) *DbResponse
UpdateOne Update one matched object.
func (*DBModel) UpsertOne ¶
func (m *DBModel) UpsertOne(query interface{}, updater interface{}) *DbResponse
UpsertOne Update one matched object, if notfound, create new document
type DBQueue2 ¶
type DBQueue2 struct { ColName string // contains filtered or unexported fields }
DBQueue2 ...
func (*DBQueue2) InitWithExpiredTime ¶
func (dbq *DBQueue2) InitWithExpiredTime(mSession *DBSession, dbName string, expiredTime time.Duration)
Init ...
func (*DBQueue2) PushWithKey ¶
func (*DBQueue2) StartConsumer ¶
StartConsumer ...
type DBQueueChannel ¶
type DBQueueChannel struct {
// contains filtered or unexported fields
}
type DBQueueConnector ¶
type DBQueueConnector struct {
// contains filtered or unexported fields
}
DBQueueConnector ...
type DBSession ¶
type DBSession struct {
// contains filtered or unexported fields
}
DBSession ..
func (*DBSession) GetMGOSession ¶
GetMGOSession : get mgo session
type DbResponse ¶
type DbStatusEnum ¶
type HTTPMethodEnum ¶
type HTTPMethodEnum struct { Get HTTPMethod Post HTTPMethod Put HTTPMethod Head HTTPMethod Delete HTTPMethod Option HTTPMethod }
HTTPMethodEnum ...
type HandleFunc ¶
type LCache ¶
type LCache struct {
// contains filtered or unexported fields
}
LCache ...
func NewLCacheRefreshMode ¶
NewLCacheRefreshMode ... maxItem: maximum item ttl: time to live (second) refreshTTL : if refreshTTL = true, when someone access item, ttl of item will be refresh
type MethodEnum ¶
type MethodEnum struct { GET *MethodValue POST *MethodValue PUT *MethodValue DELETE *MethodValue OPTIONS *MethodValue }
MethodEnum ...
type MethodValue ¶
type MethodValue struct {
Value string
}
type OnConnectedHandler ¶
OnConnectedHandler ...
type OutboundAPIRequest ¶
type OutboundAPIRequest struct { Method string `json:"method" bson:"method"` Path string `json:"path" bson:"path"` Params map[string]string `json:"params,omitempty" bson:"params,omitempty"` Headers map[string]string `json:"headers,headers" bson:"headers,omitempty"` Content string `json:"content,omitempty" bson:"content,omitempty"` }
OutboundAPIRequest Request to call other service
func NewOutboundAPIRequest ¶
func (*OutboundAPIRequest) GetContent ¶
func (req *OutboundAPIRequest) GetContent(data interface{}) error
GetContent ...
func (*OutboundAPIRequest) GetContentText ¶
func (req *OutboundAPIRequest) GetContentText() string
GetContentText ...
func (*OutboundAPIRequest) GetHeaders ¶
func (req *OutboundAPIRequest) GetHeaders() map[string]string
GetHeaders ...
func (*OutboundAPIRequest) GetMethod ¶
func (req *OutboundAPIRequest) GetMethod() *MethodValue
GetMethod ..
func (*OutboundAPIRequest) GetParams ¶
func (req *OutboundAPIRequest) GetParams() map[string]string
GetParams ...
type QueueItem ¶
type QueueItem struct { Data interface{} `json:"data,omitempty" bson:"data,omitempty"` ID *bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"` ProcessBy string `json:"processBy,omitempty" bson:"process_by,omitempty"` Version string `json:"version,omitempty" bson:"versionF,omitempty"` ProcessTimeMS int `json:"processTimeMS,omitempty" bson:"process_time_ms,omitempty"` CreatedTime *time.Time `json:"createdTime,omitempty" bson:"created_time,omitempty"` LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" bson:"last_updated_time,omitempty"` LastFail *time.Time `json:"lastFail,omitempty" bson:"last_fail,omitempty"` Keys *[]string `json:"keys,omitempty" bson:"keys,omitempty"` Log *[]string `json:"log,omitempty" bson:"log,omitempty"` }
type RequestLogEntry ¶
type RequestLogEntry struct { Status string `json:"status,omitempty" bson:"status,omitempty"` ReqURL string `json:"reqUrl,omitempty" bson:"req_url,omitempty"` ReqMethod string `json:"reqMethod,omitempty" bson:"req_method,omitempty"` ReqHeader *map[string]string `json:"reqHeader,omitempty" bson:"req_header,omitempty"` ReqFormData *map[string]string `json:"reqFormData,omitempty" bson:"req_form_data,omitempty"` ReqBody *interface{} `json:"reqBody,omitempty" bson:"req_body,omitempty"` TotalTime int64 `json:"totalTime,omitempty" bson:"total_time,omitempty"` RetryCount int `json:"retryCount,omitempty" bson:"retry_count,omitempty"` Results []*CallResult `json:"results,omitempty" bson:"results,omitempty"` ErrorLog *string `json:"errorLog,omitempty" bson:"error_log,omitempty"` Keys *[]string `json:"keys,omitempty" bson:"keys,omitempty"` Date *time.Time `bson:"date,omitempty" json:"date,omitempty"` }
RequestLogEntry ...
type RestClient ¶
type RestClient struct { BaseURL *url.URL UserAgent string // contains filtered or unexported fields }
RestClient :
func NewRESTClient ¶
func NewRESTClient(baseURL string, logName string, timeout time.Duration, maxRetryTime int, waitTime time.Duration) *RestClient
NewRESTClient : New instance of restClient
func (*RestClient) MakeHTTPRequest ¶
func (c *RestClient) MakeHTTPRequest(method HTTPMethod, headers map[string]string, params map[string]string, body interface{}, path string) (*RestResult, error)
MakeHTTPRequest :
func (*RestClient) MakeHTTPRequestWithKey ¶
func (c *RestClient) MakeHTTPRequestWithKey(method HTTPMethod, headers map[string]string, params map[string]string, body interface{}, path string, keys *[]string) (*RestResult, error)
MakeHTTPRequestWithKey
func (*RestClient) MakeRequest ¶
func (c *RestClient) MakeRequest(req OutboundAPIRequest) *APIResponse
MakeRequest ...
func (*RestClient) SetDBLog ¶
func (c *RestClient) SetDBLog(dbName string, session *DBSession)
SetDBLog :
func (*RestClient) SetDebug ¶
func (c *RestClient) SetDebug(val bool)
func (*RestClient) SetLoggerName ¶
func (c *RestClient) SetLoggerName(loggerName string)
SetLoggerName :
func (*RestClient) SetMaxRetryTime ¶
func (c *RestClient) SetMaxRetryTime(maxRetryTime int)
SetMaxRetryTime :
func (*RestClient) SetWaitTime ¶
func (c *RestClient) SetWaitTime(waitTime time.Duration)
SetWaitTime :
type RestResult ¶
type RestResult struct { Body string `json:"body,omitempty" bson:"body,omitempty"` Content []byte `json:"content,omitempty" bson:"content,omitempty"` Code int `json:"code,omitempty" bson:"code,omitempty"` }
RestResult :
type Server ¶
func (*Server) GetHandler ¶
func (s *Server) GetHandler(path string) HandleFunc
func (*Server) SetHandle ¶
func (s *Server) SetHandle(path string, handler HandleFunc)
type StatusEnum ¶
type StatusEnum struct { Ok string Error string Invalid string NotFound string Forbidden string Existed string }
StatusEnum ...