Skip to content

Commit

Permalink
feat(logstore): add parameter "mode"
Browse files Browse the repository at this point in the history
support "lite" and "standard" mode logstore
  • Loading branch information
crimson-gao committed Jun 28, 2022
1 parent 28bb45a commit e66c15b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions log_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import (
// this file is deprecated and no maintenance
// see client_logstore.go

const (
LogStore_Mode_Standard = "standard"
LogStore_Mode_Lite = "lite"
)

// LogStore defines LogStore struct
type LogStore struct {
Name string `json:"logstoreName"`
Expand All @@ -26,9 +31,11 @@ type LogStore struct {
WebTracking bool `json:"enable_tracking"`
AutoSplit bool `json:"autoSplit"`
MaxSplitShard int `json:"maxSplitShard"`

AppendMeta bool `json:"appendMeta"`
TelemetryType string `json:"telemetryType"`
HotTTL uint32 `json:"hot_ttl,omitempty"`
Mode string `json:"mode,omitempty"` // "lite" or "standard"(default), can't be modified after creation

CreateTime uint32 `json:"createTime,omitempty"`
LastModifyTime uint32 `json:"lastModifyTime,omitempty"`
Expand Down
34 changes: 34 additions & 0 deletions logstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ func (s *LogstoreTestSuite) TestLogstore() {
logstores, err := s.Project.ListLogStore()
s.Nil(err)
s.True(len(logstores) >= 1)

// test parameter "mode" of logstore, default mode is "standard"
time.Sleep(1 * 1000 * time.Millisecond)
logstore, err := s.Project.GetLogStore(logstoreName)
s.Nil(err)
s.Equal(logstore.Mode, LogStore_Mode_Standard)

time.Sleep(1 * 1000 * time.Millisecond)
configs, configCount, err := s.Project.ListConfig(0, 100)
s.Nil(err)
s.True(len(configs) >= 0)
Expand All @@ -317,6 +325,32 @@ func (s *LogstoreTestSuite) TestLogstore() {
s.Nil(err)
}

func (s *LogstoreTestSuite) TestLogstoreLiteMode() {
logstoreName := "github-test"
_ = s.Project.DeleteLogStore(logstoreName)
// create a "lite" mode logstore
lite := &LogStore{
Name: logstoreName,
TTL: 14,
ShardCount: 2,
AutoSplit: true,
MaxSplitShard: 16,
Mode: LogStore_Mode_Lite,
}
err := s.Project.CreateLogStoreV2(lite)
s.Nil(err)
time.Sleep(10 * 1000 * time.Millisecond)

// check if logstore is in "lite" mode
liteResp, err := s.Project.GetLogStore(logstoreName)
s.Nil(err)
s.Equal(liteResp.Mode, LogStore_Mode_Lite)

// clean
err = s.Project.DeleteLogStore(logstoreName)
s.Nil(err)
}

func generateLG() *LogGroup {
content := &LogContent{
Key: proto.String("demo_key"),
Expand Down

0 comments on commit e66c15b

Please # to comment.