Skip to content

Commit

Permalink
Merge pull request philchia#61 from philchia/feature/typo
Browse files Browse the repository at this point in the history
fix typo; fix issue
  • Loading branch information
philchia authored Dec 19, 2019
2 parents 24f5399 + 18ac43c commit b42f0e6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

```golang
agollo.GetStringValue(Key, defaultValue)
agollo.GetStringValueWithNameSapce(namespace, key, defaultValue)
agollo.GetStringValueWithnamespace(namespace, key, defaultValue)
```

### 获取文件内容
Expand Down
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ func (c *Client) GetAllKeys(namespace string) []string {
}

// sync namespace config
func (c *Client) sync(namesapce string) (*ChangeEvent, error) {
releaseKey := c.GetReleaseKey(namesapce)
url := configURL(c.conf, namesapce, releaseKey)
func (c *Client) sync(namespace string) (*ChangeEvent, error) {
releaseKey := c.GetReleaseKey(namespace)
url := configURL(c.conf, namespace, releaseKey)
bts, err := c.requester.request(url)
if err != nil || len(bts) == 0 {
return nil, err
Expand Down Expand Up @@ -216,7 +216,7 @@ func (c *Client) handleResult(result *result) *ChangeEvent {
c.setReleaseKey(result.NamespaceName, result.ReleaseKey)

// dump caches to file
c.dump(c.getDumpFileName())
_ = c.dump(c.getDumpFileName())

if len(ret.Changes) == 0 {
return nil
Expand Down
6 changes: 3 additions & 3 deletions conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ func TestNewConf(t *testing.T) {

func TestConfNormalize(t *testing.T) {
cases := []struct {
namesapces []string
namespaces []string
}{
{
namesapces: []string{"a", "b"},
namespaces: []string{"a", "b"},
},
}

for _, c := range cases {
conf := &Conf{NameSpaceNames: c.namesapces}
conf := &Conf{NameSpaceNames: c.namespaces}
conf.normalize()
if !strIn(conf.NameSpaceNames, defaultNamespace) {
t.Fatal("application should be in conf's namespaces")
Expand Down
8 changes: 4 additions & 4 deletions notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ type notificationRepo struct {
notifications sync.Map
}

func (n *notificationRepo) addNotificationID(namesapce string, notificationID int) bool {
_, loaded := n.notifications.LoadOrStore(namesapce, notificationID)
func (n *notificationRepo) addNotificationID(namespace string, notificationID int) bool {
_, loaded := n.notifications.LoadOrStore(namespace, notificationID)
return !loaded
}

func (n *notificationRepo) setNotificationID(namesapce string, notificationID int) {
n.notifications.Store(namesapce, notificationID)
func (n *notificationRepo) setNotificationID(namespace string, notificationID int) {
n.notifications.Store(namespace, notificationID)
}

func (n *notificationRepo) getNotificationID(namespace string) (int, bool) {
Expand Down
6 changes: 4 additions & 2 deletions poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ func (p *longPoller) addNamespaces(namespaces ...string) error {
update = true
}
}

if update {
p.pumpUpdates()
return p.pumpUpdates()
}

return nil
}

Expand All @@ -88,7 +90,7 @@ func (p *longPoller) watchUpdates() {
for {
select {
case <-timer.C:
p.pumpUpdates()
_ = p.pumpUpdates()
timer.Reset(p.pollerInterval)

case <-p.ctx.Done():
Expand Down
2 changes: 1 addition & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (r *httprequester) request(url string) ([]byte, error) {
return ioutil.ReadAll(resp.Body)
}

// Diacard all body if status code is not 200
// Discard all body if status code is not 200
_, _ = io.Copy(ioutil.Discard, resp.Body)
return nil, ErrorStatusNotOK
}

0 comments on commit b42f0e6

Please sign in to comment.