Skip to content

Commit

Permalink
Follow the naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
wangkaibo34 committed Jun 5, 2023
1 parent f9bef26 commit 428ab12
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 8 deletions.
122 changes: 116 additions & 6 deletions client_event_store.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,131 @@
package sls

const (
EVENT_STORE_TELEMETRY_TYPE = "Event"
EVENT_STORE_INDEX = "{\"max_text_len\":16384,\"ttl\":7,\"log_reduce\":false,\"line\":{\"caseSensitive\":false,\"chn\":true,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"keys\":{\"specversion\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"id\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"source\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\"\\n\",\"\\t\",\"\\r\"]},\"type\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"subject\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"datacontenttype\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"dataschema\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"data\":{\"type\":\"json\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"],\"index_all\":true,\"max_depth\":-1,\"json_keys\":{}},\"time\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"title\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"message\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]},\"status\":{\"type\":\"text\",\"doc_value\":true,\"alias\":\"\",\"caseSensitive\":false,\"chn\":false,\"token\":[\",\",\" \",\"'\",\"\\\"\",\";\",\"=\",\"(\",\")\",\"[\",\"]\",\"{\",\"}\",\"?\",\"@\",\"&\",\"<\",\">\",\"/\",\":\",\"\\n\",\"\\t\",\"\\r\"]}}}"
EventStoreTelemetryType = "Event"
EventStoreIndex = `{
"max_text_len": 16384,
"ttl": 7,
"log_reduce": false,
"line": {
"caseSensitive": false,
"chn": true,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"keys": {
"specversion": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"id": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"source": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", "\n", "\t", "\r"]
},
"type": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"subject": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"datacontenttype": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"dataschema": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"data": {
"type": "json",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"],
"index_all": true,
"max_depth": -1,
"json_keys": {}
},
"time": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"title": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"message": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
},
"status": {
"type": "text",
"doc_value": true,
"alias": "",
"caseSensitive": false,
"chn": false,
"token": [",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r"]
}
}
}`
)

func (c *Client) CreateEventStore(project string, eventStore *LogStore) error {
eventStore.TelemetryType = EVENT_STORE_TELEMETRY_TYPE
eventStore.TelemetryType = EventStoreTelemetryType
err := c.CreateLogStoreV2(project, eventStore)
if err != nil {
return err
}
return c.CreateIndexString(project, eventStore.Name, EVENT_STORE_INDEX)
return c.CreateIndexString(project, eventStore.Name, EventStoreIndex)
}

func (c *Client) UpdateEventStore(project string, eventStore *LogStore) error {
eventStore.TelemetryType = EVENT_STORE_TELEMETRY_TYPE
eventStore.TelemetryType = EventStoreTelemetryType
return c.UpdateLogStoreV2(project, eventStore)
}

Expand All @@ -28,5 +138,5 @@ func (c *Client) GetEventStore(project, name string) (*LogStore, error) {
}

func (c *Client) ListEventStore(project string, offset, size int) ([]string, error) {
return c.ListLogStoreV2(project, offset, size, EVENT_STORE_TELEMETRY_TYPE)
return c.ListLogStoreV2(project, offset, size, EventStoreTelemetryType)
}
4 changes: 2 additions & 2 deletions client_event_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (m *EventStoreTestSuite) TestClient_UpdateAndGetEventStore() {
m.Require().Equal(m.eventStoreName, eventStore.Name)
m.Require().Equal(m.ttl, eventStore.TTL)
m.Require().Equal(m.shardCnt, eventStore.ShardCount)
m.Require().Equal(EVENT_STORE_TELEMETRY_TYPE, eventStore.TelemetryType)
m.Require().Equal(EventStoreTelemetryType, eventStore.TelemetryType)

eventStore.TTL = 15
ue := m.client.UpdateEventStore(m.projectName, eventStore)
Expand All @@ -83,7 +83,7 @@ func (m *EventStoreTestSuite) TestClient_UpdateAndGetEventStore() {
m.Require().Nil(ge1)
m.Require().Equal(m.eventStoreName, eventStore1.Name)
m.Require().Equal(15, eventStore1.TTL)
m.Require().Equal(EVENT_STORE_TELEMETRY_TYPE, eventStore1.TelemetryType)
m.Require().Equal(EventStoreTelemetryType, eventStore1.TelemetryType)
de := m.client.DeleteEventStore(m.projectName, m.eventStoreName)
m.Require().Nil(de)
}

0 comments on commit 428ab12

Please sign in to comment.