本文整理汇总了Golang中duov6/com/objectstore/messaging.ObjectRequest类的典型用法代码示例。如果您正苦于以下问题:Golang ObjectRequest类的具体用法?Golang ObjectRequest怎么用?Golang ObjectRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: setOneRedisExcel
func setOneRedisExcel(request *messaging.ObjectRequest) RepositoryResponse {
response := RepositoryResponse{}
client, isError, errorMessage := getRedisExcelConnection(request)
if isError == true {
response.GetErrorResponse(errorMessage)
} else {
key := request.Controls.Namespace + "." + request.Controls.Class + "." + request.Controls.Id
value := getStringByObject(request, request.Body.Object)
err := client.Set(key, value, 0, 0, false, false)
if err != nil {
response.IsSuccess = false
request.Log("Error inserting/updating object in Redis : " + key + ", " + err.Error())
response.GetErrorResponse("Error inserting/updating one object in Redis" + err.Error())
} else {
response.IsSuccess = true
response.Message = "Successfully inserted/updated one object in Redis"
request.Log(response.Message)
}
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:26,代码来源:RedisExcel.go
示例2: GetByKey
func (repository CouchRepository) GetByKey(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting GET-BY-KEY")
response := RepositoryResponse{}
bucket, errorMessage, isError := getCouchBucket(request)
if isError == true {
response.GetErrorResponse(errorMessage)
} else {
key := request.Controls.Namespace + "." + request.Controls.Class + "." + request.Controls.Id
rawBytes, err := bucket.GetRaw(key)
var returnData map[string]interface{}
returnData = make(map[string]interface{})
json.Unmarshal(rawBytes, &returnData)
if request.Controls.SendMetaData == "false" {
delete(returnData, "__osHeaders")
}
rawBytes, err = json.Marshal(returnData)
if err != nil {
response.GetErrorResponse("Error retrieving object from couchbase")
} else {
response.GetResponseWithBody(rawBytes)
}
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:32,代码来源:Couchbase.go
示例3: GetQuery
func (repository ElasticRepository) GetQuery(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting GET-QUERY!")
response := RepositoryResponse{}
queryType := request.Body.Query.Type
switch queryType {
case "Query":
if request.Body.Query.Parameters != "*" {
fieldsInByte := executeElasticQuery(request)
if fieldsInByte != nil {
response.IsSuccess = true
response.Message = "Successfully Retrieved Data For Custom Query"
response.GetResponseWithBody(fieldsInByte)
} else {
response.IsSuccess = false
response.Message = "Aborted! Unsuccessful Retrieving Data For Custom Query"
errorMessage := response.Message
response.GetErrorResponse(errorMessage)
}
} else {
//Check if just STAR then execute GET-SEARCH method
request.Log("Redirecting to GET-SEARCH!")
return search(request, request.Body.Query.Parameters)
}
default:
return search(request, request.Body.Query.Parameters)
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:31,代码来源:Elastic.go
示例4: GetQuery
func (repository PostgresRepository) GetQuery(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting GET-QUERY")
response := RepositoryResponse{}
queryType := request.Body.Query.Type
switch queryType {
case "Query":
if request.Body.Query.Parameters != "*" {
fieldsInByte := executePostgresQuery(request)
if fieldsInByte != nil {
response.IsSuccess = true
response.Message = "Successfully Retrieved Data For Custom Query"
response.GetResponseWithBody(fieldsInByte)
} else {
response.IsSuccess = false
response.Message = "Aborted! Unsuccessful Retrieving Data For Custom Query"
errorMessage := response.Message
response.GetErrorResponse(errorMessage)
}
} else {
return repository.GetAll(request)
}
default:
request.Log(queryType + " not implemented in Postgres_SQL Db repository")
return getDefaultNotImplemented()
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:30,代码来源:PostgresRepository.go
示例5: setOneRedis
func setOneRedis(request *messaging.ObjectRequest) RepositoryResponse {
response := RepositoryResponse{}
client, isError, errorMessage := getRedisConnection(request)
keyValue := getRedisRecordID(request, nil)
if isError == true {
response.GetErrorResponse(errorMessage)
} else if keyValue != "" {
key := request.Controls.Namespace + "." + request.Controls.Class + "." + keyValue
request.Body.Object[request.Body.Parameters.KeyProperty] = keyValue
value := getStringByObject(request.Body.Object)
err := client.Set(key, value, 0, 0, false, false)
if err != nil {
response.IsSuccess = false
request.Log("Error inserting/updating object in Redis : " + key + ", " + err.Error())
response.GetErrorResponse("Error inserting/updating one object in Redis" + err.Error())
} else {
response.IsSuccess = true
response.Message = "Successfully inserted/updated one object in Redis"
request.Log(response.Message)
}
}
//Update Response
var Data []map[string]interface{}
Data = make([]map[string]interface{}, 1)
var actualData map[string]interface{}
actualData = make(map[string]interface{})
actualData["ID"] = keyValue
Data[0] = actualData
response.Data = Data
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:35,代码来源:Redis.go
示例6: InsertSingle
func (repository MongoRepository) InsertSingle(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting INSERT-SINGLE")
response := RepositoryResponse{}
collection, isError, errorMessage := getMongoConnection(request)
key := getMongoDBRecordID(request, nil)
if isError == true {
response.GetErrorResponse(errorMessage)
} else if key != "" {
request.Body.Object[request.Body.Parameters.KeyProperty] = key
request.Body.Object["_id"] = request.Controls.Namespace + "." + request.Controls.Class + "." + key
err := collection.Insert(bson.M(request.Body.Object))
if err != nil {
response.IsSuccess = false
response.GetErrorResponse("Error inserting one object in mongo" + err.Error())
} else {
response.IsSuccess = true
response.Message = "Successfully inserted one object in Mongo"
request.Log(response.Message)
}
}
var Data []map[string]interface{}
Data = make([]map[string]interface{}, 1)
var actualData map[string]interface{}
actualData = make(map[string]interface{})
actualData["ID"] = key
Data[0] = actualData
response.Data = Data
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:31,代码来源:Mongo.go
示例7: GetByKey
func (repository CassandraRepository) GetByKey(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting Get-BY-KEY!")
response := RepositoryResponse{}
session, isError, errorMessage := getCassandraConnection(request)
if isError == true {
response.GetErrorResponse(errorMessage)
} else {
isError = false
//get primary key field name
iter := session.Query("select type, column_name from system.schema_columns WHERE keyspace_name='" + getSQLnamespace(request) + "' AND columnfamily_name='" + request.Controls.Class + "'").Iter()
my1, _ := iter.SliceMap()
iter.Close()
fieldName := ""
for _, value := range my1 {
if value["type"].(string) == "partition_key" {
fieldName = value["column_name"].(string)
break
}
}
parameter := request.Controls.Id
iter2 := session.Query("SELECT * FROM " + request.Controls.Class + " where " + fieldName + " = '" + parameter + "'").Iter()
my, isErr := iter2.SliceMap()
iter2.Close()
if request.Controls.SendMetaData == "false" {
for index, arrVal := range my {
for key, _ := range arrVal {
if key == "osheaders" {
delete(my[index], key)
}
}
}
}
byteValue, errMarshal := json.Marshal(my)
if errMarshal != nil {
response.IsSuccess = false
response.GetErrorResponse("Error getting values for one object in Cassandra" + isErr.Error())
} else {
response.IsSuccess = true
response.GetResponseWithBody(byteValue)
response.Message = "Successfully retrieved values for one object in Cassandra"
request.Log(response.Message)
}
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:59,代码来源:Cassandra.go
示例8: GetAll
func (repository CassandraRepository) GetAll(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting GET-ALL!")
response := RepositoryResponse{}
session, isError, errorMessage := getCassandraConnection(request)
if isError == true {
response.GetErrorResponse(errorMessage)
} else {
isError = false
iter2 := session.Query("SELECT * FROM " + request.Controls.Class).Iter()
my, isErr := iter2.SliceMap()
iter2.Close()
skip := 0
if request.Extras["skip"] != nil {
skip, _ = strconv.Atoi(request.Extras["skip"].(string))
}
take := len(my)
if request.Extras["take"] != nil {
take, _ = strconv.Atoi(request.Extras["take"].(string))
}
fmt.Println(reflect.TypeOf(my))
if request.Controls.SendMetaData == "false" {
for index, arrVal := range my {
for key, _ := range arrVal {
if key == "osheaders" {
delete(my[index], key)
}
}
}
}
byteValue, errMarshal := json.Marshal(my[skip:(skip + take)])
if errMarshal != nil {
response.IsSuccess = false
response.GetErrorResponse("Error getting values for all objects in Cassandra" + isErr.Error())
} else {
response.IsSuccess = true
response.GetResponseWithBody(byteValue)
response.Message = "Successfully retrieved values for all objects in Cassandra"
request.Log(response.Message)
}
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:54,代码来源:Cassandra.go
示例9: Store
func (r QueuedStorageEngine) Store(request *messaging.ObjectRequest) (response repositories.RepositoryResponse) {
conn, err := amqp.Dial("amqp://guest:[email protected]:5672/")
failOnError(err, "Failed to connect to RabbitMQ")
defer conn.Close()
ch, err := conn.Channel()
failOnError(err, "Failed to open a channel")
defer ch.Close()
err = ch.ExchangeDeclare(
"publisher_01", // name
"direct", // type
true, // durable
false, // auto-deleted
false, // internal
false, // no-wait
nil, // arguments
)
failOnError(err, "Failed to declare an exchange")
body, errMarshal := json.Marshal(request)
if errMarshal != nil {
response.Message = "Conversion to JSON failed!"
request.Log(response.Message)
} else {
response.Message = "Conversion to JSON Success!"
request.Log(response.Message)
log.Printf(" [x] Sent %s", body)
}
err = ch.Publish(
"publisher_01", // exchange
"Queued", // routing key
false, // mandatory
false, // immediate
amqp.Publishing{
// ContentType: "text/plain",
ContentType: "*messaging.ObjectRequest",
Body: body,
})
failOnError(err, "Failed to publish a message")
if err == nil {
response.IsSuccess = true
}
//log.Printf(" [x] Sent %s", body)
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:52,代码来源:QueuedStorageEngine.go
示例10: getRedisConnection
func getRedisConnection(request *messaging.ObjectRequest) (client *goredis.Redis, isError bool, errorMessage string) {
isError = false
client, err := goredis.DialURL("tcp://@" + request.Configuration.ServerConfiguration["REDIS"]["Host"] + ":" + request.Configuration.ServerConfiguration["REDIS"]["Port"] + "/0?timeout=10s&maxidle=1")
if err != nil {
isError = true
errorMessage = err.Error()
request.Log("Error! Can't connect to server!error")
}
request.Log("Reusing existing GoRedis connection")
return
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:13,代码来源:Redis.go
示例11: DeleteMultiple
func (repository ElasticRepository) DeleteMultiple(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting DELETE-MULTIPLE")
response := RepositoryResponse{}
conn := getConnection()(request)
for _, object := range request.Body.Objects {
key := getNoSqlKeyById(request, object)
request.Log("Deleting single object from Elastic Search : " + key)
_, err := conn.Delete(request.Controls.Namespace, request.Controls.Class, key, nil)
_, err = conn.Delete(getKibanaElasticName(request), getKibanaElasticName(request), key, nil)
if err != nil {
errorMessage := "Elastic Search single delete error : " + err.Error()
request.Log(errorMessage)
response.GetErrorResponse(errorMessage)
} else {
response.IsSuccess = true
response.Message = "Successfully deleted one in elastic search"
request.Log(response.Message)
}
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:25,代码来源:Elastic.go
示例12: DeleteSingle
func (repository CouchRepository) DeleteSingle(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting DELETE-SINGLE")
response := RepositoryResponse{}
bucket, errorMessage, isError := getCouchBucket(request)
if isError == true {
response.GetErrorResponse(errorMessage)
} else {
key := request.Controls.Namespace + "." + request.Controls.Class + "." + request.Controls.Id
request.Log("Deleting object from couchbase : " + key)
err := bucket.Delete(key)
if err != nil {
response.IsSuccess = false
request.Log("Error deleting object from couchbase : " + key + ", " + err.Error())
response.GetErrorResponse("Error deleting one object in Couchbase" + err.Error())
} else {
response.IsSuccess = true
response.Message = "Successfully deleted one object in Coucahbase"
request.Log(response.Message)
}
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:25,代码来源:Couchbase.go
示例13: UpdateMultiple
func (repository MysqlRepository) UpdateMultiple(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting UPDATE-MULTIPLE")
response := RepositoryResponse{}
session, isError, errorMessage := getMysqlConnection(request)
if isError == true {
response.GetErrorResponse(errorMessage)
} else {
for i := 0; i < len(request.Body.Objects); i++ {
noOfElements := len(request.Body.Objects[i]) - 1
var keyUpdate = make([]string, noOfElements)
var valueUpdate = make([]string, noOfElements)
var startIndex = 0
for key, value := range request.Body.Objects[i] {
if key != request.Body.Parameters.KeyProperty {
if key != "__osHeaders" {
keyUpdate[startIndex] = key
valueUpdate[startIndex] = value.(string)
startIndex = startIndex + 1
} else {
keyUpdate[startIndex] = "osHeaders"
valueUpdate[startIndex] = ConvertOsheaders(value.(messaging.ControlHeaders))
startIndex = startIndex + 1
}
}
}
var argValueList string
//Build the query string
for i := 0; i < noOfElements; i++ {
if i != noOfElements-1 {
argValueList = argValueList + keyUpdate[i] + " = " + "'" + valueUpdate[i] + "'" + ", "
} else {
argValueList = argValueList + keyUpdate[i] + " = " + "'" + valueUpdate[i] + "'"
}
}
//DEBUG USE : Display Query information
// fmt.Println("Table Name : " + request.Controls.Class)
// fmt.Println("Value list : " + argValueList)
request.Log("UPDATE " + getSQLnamespace(request) + "." + request.Controls.Class + " SET " + argValueList + " WHERE " + request.Body.Parameters.KeyProperty + " =" + "'" + request.Body.Objects[i][request.Body.Parameters.KeyProperty].(string) + "'")
_, err := session.Query("UPDATE " + getSQLnamespace(request) + "." + request.Controls.Class + " SET " + argValueList + " WHERE " + request.Body.Parameters.KeyProperty + " =" + "'" + request.Body.Objects[i][request.Body.Parameters.KeyProperty].(string) + "'")
if err != nil {
response.IsSuccess = false
request.Log("Error updating object in MySQL : " + getNoSqlKey(request) + ", " + err.Error())
response.GetErrorResponse("Error updating one object in MySQL because no match was found!" + err.Error())
} else {
response.IsSuccess = true
response.Message = "Successfully updating one object in MySQL "
request.Log(response.Message)
}
}
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:60,代码来源:MysqlRepository.go
示例14: DeleteMultiple
func (repository CouchRepository) DeleteMultiple(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting DELETE_MULTIPLE")
response := RepositoryResponse{}
bucket, errorMessage, isError := getCouchBucket(request)
if isError == true {
response.GetErrorResponse(errorMessage)
} else {
for _, obj := range request.Body.Objects {
key := getNoSqlKeyById(request, obj)
request.Log("Deleting object from couchbase : " + key)
err := bucket.Delete(key)
if err != nil {
response.IsSuccess = false
request.Log("Error deleting object from couchbase : " + key + ", " + err.Error())
response.GetErrorResponse("Error deleting Multiple objects in Couchbase" + err.Error())
} else {
response.IsSuccess = true
response.Message = "Successfully deleted Multiple objects in Coucahbase"
request.Log(response.Message)
}
}
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:27,代码来源:Couchbase.go
示例15: getRedisExcelConnection
func getRedisExcelConnection(request *messaging.ObjectRequest) (client *goredis.Redis, isError bool, errorMessage string) {
isError = false
client, err := goredis.DialURL("tcp://@127.0.0.1:6379/0?timeout=10s&maxidle=1")
if err != nil {
isError = true
errorMessage = err.Error()
request.Log("Error! Can't connect to server!error")
}
request.Log("Reusing existing GoRedis connection")
return
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:14,代码来源:RedisExcel.go
示例16: GetAll
func (repository CouchRepository) GetAll(request *messaging.ObjectRequest) RepositoryResponse {
request.Log("Starting GET-ALL")
response := RepositoryResponse{}
bucket, errorMessage, isError := getCouchBucket(request)
if isError == true {
response.GetErrorResponse(errorMessage)
} else {
//Get all IDs
viewResult, err := bucket.View("dev_allkeytemp", "allkeystemp", nil)
//Iterate check for pattern and choose only desired IDs
pattern := request.Controls.Namespace + "." + request.Controls.Class + "."
var idArray []string
for _, row := range viewResult.Rows {
if strings.Contains((row.Key).(string), pattern) {
idArray = append(idArray, (row.Key).(string))
}
}
//read all data for fetched days and return
var returnDataMap []map[string]interface{}
data, err := bucket.GetBulkRaw(idArray)
for key, _ := range data {
var tempData map[string]interface{}
tempData = make(map[string]interface{})
json.Unmarshal(data[key], &tempData)
if request.Controls.SendMetaData == "false" {
delete(tempData, "__osHeaders")
}
returnDataMap = append(returnDataMap, tempData)
}
rawBytes, err := json.Marshal(returnDataMap)
if err != nil {
fmt.Println(err.Error())
response.GetErrorResponse("Error retrieving object from couchbase : " + err.Error())
} else {
response.GetResponseWithBody(rawBytes)
}
}
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:49,代码来源:Couchbase.go
示例17: startAtomicOperation
func startAtomicOperation(request *messaging.ObjectRequest, repositoryList []repositories.AbstractRepository, successAction int, failAction int) (response repositories.RepositoryResponse) {
canRollback := false
if repositoryList == nil {
fmt.Println("NIL REPOSITORIES")
} else {
fmt.Println("REPOSITORIES FOUND!")
fmt.Print("Fetched Repositories : ")
fmt.Println(repositoryList)
}
for _, repository := range repositoryList {
if repository != nil {
request.Log("Executing repository : " + repository.GetRepositoryName())
tmpResponse := repositories.Execute(request, repository)
canBreak := false
if tmpResponse.IsSuccess {
request.Log("Executing repository : " + repository.GetRepositoryName() + " - Success")
switch successAction {
case 1:
response = tmpResponse
continue
case 3:
response = tmpResponse
canBreak = true
}
} else {
request.Log("Executing repository : " + repository.GetRepositoryName() + " - Failed")
switch failAction {
case 1:
continue
case 2:
canRollback = true
canBreak = true
case 3:
response = tmpResponse
canBreak = true
}
if canBreak == true {
break
}
//1 = COMMIT, 2 = ROLLBACK, 3 = BREAK
}
} else {
fmt.Println("NIL REPOSITORY FOUND!")
continue
}
}
if canRollback {
request.Log("Transaction failed Rollbacking!!!")
}
return
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:59,代码来源:ReplicatedStorageEngine.go
示例18: setManyRedis
func setManyRedis(request *messaging.ObjectRequest) RepositoryResponse {
response := RepositoryResponse{}
client, isError, errorMessage := getRedisConnection(request)
var idData map[string]interface{}
idData = make(map[string]interface{})
if isError == true {
response.GetErrorResponse(errorMessage)
} else {
isError := false
index := 0
for _, object := range request.Body.Objects {
index++
keyValue := getRedisRecordID(request, object)
if keyValue == "" {
response.IsSuccess = false
response.Message = "Failed inserting multiple object in Cassandra"
request.Log(response.Message)
request.Log("Inavalid ID request")
return response
}
key := request.Controls.Namespace + "." + request.Controls.Class + "." + keyValue
object[request.Body.Parameters.KeyProperty] = keyValue
idData[strconv.Itoa(index)] = keyValue
value := getStringByObject(object)
err := client.Set(key, value, 0, 0, false, false)
if err != nil {
isError = true
errorMessage = err.Error()
break
}
}
if isError == true {
response.IsSuccess = false
request.Log("Error inserting/updating multiple objects in Redis : " + errorMessage)
response.GetErrorResponse("Error inserting/updating multiple objects in Redis" + errorMessage)
} else {
response.IsSuccess = true
response.Message = "Successfully inserted/updated multiple objects in Redis"
request.Log(response.Message)
}
}
//Update Response
var DataMap []map[string]interface{}
DataMap = make([]map[string]interface{}, 1)
var actualInput map[string]interface{}
actualInput = make(map[string]interface{})
actualInput["ID"] = idData
DataMap[0] = actualInput
response.Data = DataMap
return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:59,代码来源:Redis.go
示例19: getMongoConnection
func getMongoConnection(request *messaging.ObjectRequest) (client *mgo.Collection, isError bool, errorMessage string) {
isError = false
session, err := mgo.Dial(request.Configuration.ServerConfiguration["MONGO"]["Url"])
if err != nil {
isError = false
errorMessage = err.Error()
request.Log("Mongo connection initilizing failed!")
}
namespace := getSQLnamespace(request)
client = session.DB(namespace).C(request.Controls.Class)
return
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:15,代码来源:Mongo.go
示例20: getPostgresReportingFieldOrder
func getPostgresReportingFieldOrder(request *messaging.ObjectRequest) []string {
var returnArray []string
//read fields
byteValue := executePostgresReportingGetFields(request)
err := json.Unmarshal(byteValue, &returnArray)
if err != nil {
request.Log("Converstion of Json Failed!")
returnArray = make([]string, 1)
returnArray[0] = "nil"
return returnArray
}
return returnArray
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:15,代码来源:PostgresReportingRepository.go
注:本文中的duov6/com/objectstore/messaging.ObjectRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论