Skip to content

Commit

Permalink
Merge pull request moby#3 from aliyun-fc/rebase-docker
Browse files Browse the repository at this point in the history
change the method of new logstore object
  • Loading branch information
wanghq committed Jun 19, 2017
2 parents 90c18a7 + 2dfb234 commit f1b6a66
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,6 +7,7 @@
*.test
.*.swp
.DS_Store
.idea
# a .bashrc may be added to customize the build environment
.bashrc
.gopath/
Expand Down
2 changes: 1 addition & 1 deletion COMPILE_GUIDANCE.md
Expand Up @@ -3,7 +3,7 @@
* if you need to update dependent package in vendor, you need to add or update package in hack/vendor.sh file, like this:

```
clone git github.com/galaxydi/go-loghub 228ca31911b37dd900a5ab9a3fbdc66c2d88ab16
clone git github.com/aliyun-fc/go-loghub 5c958ab5f7b2cd8f9e965fc0724fa3d51941d636
clone git github.com/cloudflare/golz4 ef862a3cdc58a6f1fee4e3af3d44fbe279194cde
clone git github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998
```
Expand Down
2 changes: 1 addition & 1 deletion daemon/logger/alilogs/alilogs.go
Expand Up @@ -7,8 +7,8 @@ import (
"time"

"github.com/Sirupsen/logrus"
"github.com/aliyun-fc/go-loghub"
"github.com/docker/docker/daemon/logger"
"github.com/galaxydi/go-loghub"
"github.com/golang/protobuf/proto"
)

Expand Down
2 changes: 1 addition & 1 deletion daemon/logger/alilogs/alilogs_test.go
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
"time"

sls "github.com/aliyun-fc/go-loghub"
"github.com/docker/docker/daemon/logger"
sls "github.com/galaxydi/go-loghub"
"github.com/gogo/protobuf/proto"
)

Expand Down
26 changes: 5 additions & 21 deletions daemon/logger/alilogs/logapi.go
Expand Up @@ -3,11 +3,8 @@
package alilogs

import (
"errors"
"fmt"

"github.com/Sirupsen/logrus"
"github.com/galaxydi/go-loghub"
"github.com/aliyun-fc/go-loghub"
)

// AliLogAPI define log api interface
Expand Down Expand Up @@ -48,27 +45,14 @@ func (client *AliLogClient) getLogStore(endpoint, projectName, logstoreName, acc
if err != nil {
return nil, err
}
logStore, err := logProject.GetLogStore(logstoreName)
if err != nil {
// return loghub error message directly
errorMsg := fmt.Sprintf("Could not get ali logstore %s from project %s due to '%v'", logstoreName, projectName, err)
logrus.WithFields(logrus.Fields{
"error": err,
}).Error(errorMsg)
return nil, errors.New(errorMsg)
}
// sls.NewLogStore returns no error
logStore, _ := sls.NewLogStore(logstoreName, logProject)
return logStore, nil
}

func (client *AliLogClient) getLogProject(projectName, endpoint, accessKeyID, accessKeySecret, securityToken string) (*sls.LogProject, error) {
logProject, err := sls.NewLogProject(projectName, endpoint, accessKeyID, accessKeySecret)
if err != nil {
errorMsg := fmt.Sprintf("get project fail due to '%s'", err.Error())
logrus.WithFields(logrus.Fields{
"error": err,
}).Error(errorMsg)
return nil, errors.New(errorMsg)
}
// sls.NewLogProject returns no error
logProject, _ := sls.NewLogProject(projectName, endpoint, accessKeyID, accessKeySecret)
if securityToken != "" {
logProject.WithToken(securityToken)
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/logger/alilogs/mock_client_test.go
Expand Up @@ -3,7 +3,7 @@ package alilogs
import (
"fmt"

sls "github.com/galaxydi/go-loghub"
sls "github.com/aliyun-fc/go-loghub"
)

type errorType int
Expand Down
2 changes: 1 addition & 1 deletion hack/vendor.sh
Expand Up @@ -123,7 +123,7 @@ clone git github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c
clone git gopkg.in/fsnotify.v1 v1.2.11

# alilogs deps
clone git github.com/galaxydi/go-loghub 228ca31911b37dd900a5ab9a3fbdc66c2d88ab16
clone git github.com/aliyun-fc/go-loghub 5c958ab5f7b2cd8f9e965fc0724fa3d51941d636
clone git github.com/cloudflare/golz4 ef862a3cdc58a6f1fee4e3af3d44fbe279194cde
clone git github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998

Expand Down
Expand Up @@ -5,8 +5,8 @@ API Reference :
* [Chinese](https://help.aliyun.com/document_detail/29007.html)
* [English](https://intl.aliyun.com/help/doc-detail/29007.htm)

[![Build Status](https://travis-ci.org/galaxydi/go-loghub.svg?branch=master)](https://travis-ci.org/galaxydi/go-loghub)
[![Coverage Status](https://coveralls.io/repos/github/galaxydi/go-loghub/badge.svg?branch=master&foo=bar)](https://coveralls.io/github/galaxydi/go-loghub?branch=master&foo=bar)
[![Build Status](https://travis-ci.org/aliyun-fc/go-loghub.svg?branch=master)](https://travis-ci.org/aliyun-fc/go-loghub)
[![Coverage Status](https://coveralls.io/repos/github/aliyun-fc/go-loghub/badge.svg?branch=master&foo=bar)](https://coveralls.io/github/aliyun-fc/go-loghub?branch=master&foo=bar)


# Install Instruction
Expand All @@ -23,7 +23,7 @@ go get github.com/stretchr/testify/suite
### LogHub Golang SDK

```
go get github.com/galaxydi/go-loghub
go get github.com/aliyun-fc/go-loghub
```

# Example
Expand Down
Expand Up @@ -16,7 +16,7 @@ type LogProject struct {
SecurityToken string
}

// NewLogProject creates a new SLS project.
// NewLogProject new a SLS project object.
func NewLogProject(name, endpoint, accessKeyID, accessKeySecret string) (p *LogProject, err error) {
p = &LogProject{
Name: name,
Expand Down
Expand Up @@ -25,6 +25,15 @@ type LogStore struct {
project *LogProject
}

// NewLogProject new a SLS logStore object.
func NewLogStore(logstoreName string, project *LogProject) (*LogStore, error) {
l := &LogStore{
Name: logstoreName,
project: project,
}
return l, nil
}

// Shard defines shard struct
type Shard struct {
ShardID int `json:"shardID"`
Expand Down Expand Up @@ -287,9 +296,9 @@ func (s *LogStore) GetHistograms(topic string, from int64, to int64, queryExp st
return nil, err
}
getHistogramsResponse := GetHistogramsResponse{
Progress: r.Header[ProgressHeader][0],
Count: count,
Histograms: histograms,
Progress: r.Header[ProgressHeader][0],
Count: count,
Histograms: histograms,
}

return &getHistogramsResponse, nil
Expand Down
Expand Up @@ -2,16 +2,16 @@ package sls

// GetHistogramsResponse defines response from GetHistograms call
type SingleHistogram struct {
Progress string `json:"progress"`
Count int64 `json:"count"`
From int64 `json:"from"`
To int64 `json:"to"`
Progress string `json:"progress"`
Count int64 `json:"count"`
From int64 `json:"from"`
To int64 `json:"to"`
}

type GetHistogramsResponse struct {
Progress string `json:"progress"`
Count int64 `json:"count"`
Histograms []SingleHistogram `json:"histograms"`
Progress string `json:"progress"`
Count int64 `json:"count"`
Histograms []SingleHistogram `json:"histograms"`
}

// GetLogsResponse defines response from GetLogs call
Expand Down

0 comments on commit f1b6a66

Please sign in to comment.