Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(74)

Side by Side Diff: state/api/logger/logger.go

Issue 13691043: Implement the client part for the logger worker.
Patch Set: Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details.
3
4 package logger
5
6 import (
7 "fmt"
8
9 "launchpad.net/juju-core/state/api/common"
10 "launchpad.net/juju-core/state/api/params"
11 "launchpad.net/juju-core/state/api/watcher"
12 )
13
14 // State provides access to an logger worker's view of the state.
15 type State struct {
16 caller common.Caller
17 }
18
19 // NewState returns a version of the state that provides functionality
20 // required by the logger worker.
21 func NewState(caller common.Caller) *State {
22 return &State{caller}
23 }
24
25 func (st *State) LoggingConfig(tag string) (string, error) {
wallyworld 2013/09/13 02:50:33 Doc string please. At first glance, I don't know w
26 var results params.StringResults
27 args := params.Entities{
28 Entities: []params.Entity{{Tag: tag}},
29 }
30 err := st.caller.Call("Logger", "", "LoggingConfig", args, &results)
31 if err != nil {
32 // TODO: Not directly tested
33 return "", err
34 }
35 if len(results.Results) != 1 {
36 // TODO: Not directly tested
37 return "", fmt.Errorf("expected one result, got %d", len(results .Results))
38 }
39 result := results.Results[0]
40 if err := result.Error; err != nil {
41 return "", err
42 }
43 return result.Result, nil
44 }
45
46 func (st *State) WatchLoggingConfig(agentTag string) (watcher.NotifyWatcher, err or) {
wallyworld 2013/09/13 02:50:33 Doc string again. Also, why agentTag here and tag
47 var results params.NotifyWatchResults
48 args := params.Entities{
49 Entities: []params.Entity{{Tag: agentTag}},
50 }
51 err := st.caller.Call("Logger", "", "WatchLoggingConfig", args, &results )
52 if err != nil {
53 // TODO: Not directly tested
54 return nil, err
55 }
56 if len(results.Results) != 1 {
57 // TODO: Not directly tested
58 return nil, fmt.Errorf("expected one result, got %d", len(result s.Results))
59 }
60 result := results.Results[0]
61 if result.Error != nil {
62 // TODO: Not directly tested
63 return nil, result.Error
64 }
65 w := watcher.NewNotifyWatcher(st.caller, result)
66 return w, nil
67 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b