Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: client/cmd/logdog_butler/main.go

Issue 1610993002: LogDog: Add collector service implementation. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
11 "net/http" 11 "net/http"
12 "os" 12 "os"
13 "os/signal" 13 "os/signal"
14 "runtime/pprof" 14 "runtime/pprof"
15 "time" 15 "time"
16 16
17 "github.com/luci/luci-go/client/authcli" 17 "github.com/luci/luci-go/client/authcli"
18 "github.com/luci/luci-go/client/internal/flags/multiflag" 18 "github.com/luci/luci-go/client/internal/flags/multiflag"
19 "github.com/luci/luci-go/client/internal/logdog/butler" 19 "github.com/luci/luci-go/client/internal/logdog/butler"
20 "github.com/luci/luci-go/client/internal/logdog/butler/output" 20 "github.com/luci/luci-go/client/internal/logdog/butler/output"
21 "github.com/luci/luci-go/common/auth" 21 "github.com/luci/luci-go/common/auth"
22 "github.com/luci/luci-go/common/clock/clockflag" 22 "github.com/luci/luci-go/common/clock/clockflag"
23 "github.com/luci/luci-go/common/gcloud/gcps" 23 "github.com/luci/luci-go/common/gcloud/gcps"
24 "github.com/luci/luci-go/common/logdog/types" 24 "github.com/luci/luci-go/common/logdog/types"
25 log "github.com/luci/luci-go/common/logging" 25 log "github.com/luci/luci-go/common/logging"
26 "github.com/luci/luci-go/common/logging/gologger" 26 "github.com/luci/luci-go/common/logging/gologger"
27 "github.com/luci/luci-go/common/paniccatcher" 27 "github.com/luci/luci-go/common/paniccatcher"
28 "github.com/maruel/subcommands" 28 "github.com/maruel/subcommands"
29 "golang.org/x/net/context" 29 "golang.org/x/net/context"
30 "google.golang.org/cloud"
31 ) 30 )
32 31
33 const ( 32 const (
34 // flagErrorReturnCode is returned when there is an error with the Butle r's 33 // flagErrorReturnCode is returned when there is an error with the Butle r's
35 // command-line configuration. 34 // command-line configuration.
36 configErrorReturnCode = 2 35 configErrorReturnCode = 2
37 36
38 // runtimeErrorReturnCode is returned when the execution fails due to a Butler 37 // runtimeErrorReturnCode is returned when the execution fails due to a Butler
39 // error. This is intended to help differentiate Butler errors from 38 // error. This is intended to help differentiate Butler errors from
40 // passthrough bootstrapped subprocess errors. 39 // passthrough bootstrapped subprocess errors.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 126
128 client, err := auth.NewAuthenticator(auth.SilentLogin, opts).Cli ent() 127 client, err := auth.NewAuthenticator(auth.SilentLogin, opts).Cli ent()
129 if err != nil { 128 if err != nil {
130 return nil, err 129 return nil, err
131 } 130 }
132 a.client = client 131 a.client = client
133 } 132 }
134 return a.client, nil 133 return a.client, nil
135 } 134 }
136 135
137 func (a *butlerApplication) authenticatedContext(ctx context.Context, project st ring) (context.Context, error) {
dnj (Google) 2016/01/21 04:36:24 No longer needed w/ Pub/Sub changes.
138 if project == "" {
139 return nil, errors.New("must supply a project name")
140 }
141
142 client, err := a.authenticatedClient(ctx)
143 if err != nil {
144 return nil, err
145 }
146
147 return cloud.WithContext(ctx, project, client), nil
148 }
149
150 func (a *butlerApplication) configOutput() (output.Output, error) { 136 func (a *butlerApplication) configOutput() (output.Output, error) {
151 factory := a.outputConfig.getFactory() 137 factory := a.outputConfig.getFactory()
152 if factory == nil { 138 if factory == nil {
153 return nil, errors.New("main: No output is configured") 139 return nil, errors.New("main: No output is configured")
154 } 140 }
155 141
156 output, err := factory.configOutput(a) 142 output, err := factory.configOutput(a)
157 if err != nil { 143 if err != nil {
158 return nil, err 144 return nil, err
159 } 145 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 303
318 paniccatcher.Do(func() { 304 paniccatcher.Do(func() {
319 rc = mainImpl(ctx, os.Args[1:]) 305 rc = mainImpl(ctx, os.Args[1:])
320 }, func(p *paniccatcher.Panic) { 306 }, func(p *paniccatcher.Panic) {
321 log.Fields{ 307 log.Fields{
322 "panic.error": p.Reason, 308 "panic.error": p.Reason,
323 }.Errorf(ctx, "Panic caught in main:\n%s", p.Stack) 309 }.Errorf(ctx, "Panic caught in main:\n%s", p.Stack)
324 rc = runtimeErrorReturnCode 310 rc = runtimeErrorReturnCode
325 }) 311 })
326 } 312 }
OLDNEW
« no previous file with comments | « no previous file | client/cmd/logdog_butler/output_pubsub.go » ('j') | client/cmd/logdog_butler/output_pubsub.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698