本文整理汇总了Golang中github.com/aws/amazon-ecs-agent/agent/logger.ForModule函数的典型用法代码示例。如果您正苦于以下问题:Golang ForModule函数的具体用法?Golang ForModule怎么用?Golang ForModule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ForModule函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
"io/ioutil"
"net"
"net/http"
"net/url"
"reflect"
"strings"
"time"
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/utils"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/private/protocol/json/jsonutil"
"github.com/gorilla/websocket"
)
var log = logger.ForModule("ws client")
const (
// ServiceName defines the service name for the agent. This is used to sign messages
// that are sent to the backend.
ServiceName = "ecs"
// wsConnectTimeout specifies the default connection timeout to the backend.
wsConnectTimeout = 30 * time.Second
// readBufSize is the size of the read buffer for the ws connection.
readBufSize = 4096
// writeBufSize is the size of the write buffer for the ws connection.
writeBufSize = 32768
)
示例2:
"fmt"
"sync"
"github.com/pborman/uuid"
"github.com/aws/amazon-ecs-agent/agent/api"
"github.com/aws/amazon-ecs-agent/agent/config"
ecsengine "github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/stats/resolver"
"github.com/aws/amazon-ecs-agent/agent/tcs/model/ecstcs"
"github.com/aws/aws-sdk-go/aws"
"golang.org/x/net/context"
)
var log = logger.ForModule("stats")
// DockerContainerMetadataResolver implements ContainerMetadataResolver for
// DockerTaskEngine.
type DockerContainerMetadataResolver struct {
dockerTaskEngine *ecsengine.DockerTaskEngine
}
// Engine defines methods to be implemented by the engine struct. It is
// defined to make testing easier.
type Engine interface {
GetInstanceMetrics() (*ecstcs.MetricsMetadata, []*ecstcs.TaskMetric, error)
}
// DockerStatsEngine is used to monitor docker container events and to report
// utlization metrics of the same.
示例3: MetadataV1RequestHandlerMaker
"encoding/json"
"net/http"
"strconv"
"sync"
"time"
"github.com/aws/amazon-ecs-agent/agent/api"
"github.com/aws/amazon-ecs-agent/agent/config"
"github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/utils"
"github.com/aws/amazon-ecs-agent/agent/version"
)
var log = logger.ForModule("Handlers")
const statusBadRequest = 400
const statusNotImplemented = 501
const statusOK = 200
const statusInternalServerError = 500
const dockerIdQueryField = "dockerid"
const taskArnQueryField = "taskarn"
type RootResponse struct {
AvailableCommands []string
}
func MetadataV1RequestHandlerMaker(containerInstanceArn *string, cfg *config.Config) func(http.ResponseWriter, *http.Request) {
resp := &MetadataResponse{
示例4: NewTaskEngine
// Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
// The 'engine' package contains code for interacting with container-running backends and handling events from them.
// It supports Docker as the sole task engine type.
package engine
import (
"github.com/aws/amazon-ecs-agent/agent/config"
"github.com/aws/amazon-ecs-agent/agent/credentials"
"github.com/aws/amazon-ecs-agent/agent/logger"
)
var log = logger.ForModule("TaskEngine")
// NewTaskEngine returns a default TaskEngine
func NewTaskEngine(cfg *config.Config, client DockerClient, credentialsManager credentials.Manager) TaskEngine {
return NewDockerTaskEngine(cfg, client, credentialsManager)
}
示例5: HandleEngineEvents
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
package eventhandler
import (
"github.com/aws/amazon-ecs-agent/agent/api"
"github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/statemanager"
)
var log = logger.ForModule("eventhandler")
// statesaver is a package-wise statemanager which may be used to save any
// changes to a task or container's SentStatus
var statesaver statemanager.Saver = statemanager.NewNoopStateManager()
func HandleEngineEvents(taskEngine engine.TaskEngine, client api.ECSClient, saver statemanager.Saver) {
statesaver = saver
for {
taskEvents, containerEvents := taskEngine.TaskEvents()
for taskEvents != nil && containerEvents != nil {
select {
case event, open := <-containerEvents:
if !open {
containerEvents = nil
示例6:
"github.com/aws/amazon-ecs-agent/agent/acs/update_handler/os"
"github.com/aws/amazon-ecs-agent/agent/config"
"github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/httpclient"
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/sighandlers"
"github.com/aws/amazon-ecs-agent/agent/sighandlers/exitcodes"
"github.com/aws/amazon-ecs-agent/agent/statemanager"
"github.com/aws/amazon-ecs-agent/agent/utils"
"github.com/aws/amazon-ecs-agent/agent/utils/ttime"
"github.com/aws/amazon-ecs-agent/agent/wsclient"
"github.com/aws/aws-sdk-go/aws"
"github.com/cihub/seelog"
)
var log = logger.ForModule("updater")
const desiredImageFile = "desired-image"
// update describes metadata around an update 2-phase request
type updater struct {
stage updateStage
stageTime time.Time
// downloadMessageID is the most recent message id seen for this update id
downloadMessageID string
// updateID is a unique identifier for this update used to determine if a
// new update request, even with a different message id, is a duplicate or
// not
updateID string
fs os.FileSystem
acs wsclient.ClientServer
示例7:
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"reflect"
"strconv"
"strings"
"github.com/aws/amazon-ecs-agent/agent/ec2"
"github.com/aws/amazon-ecs-agent/agent/engine/dockerclient"
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/utils"
)
var log = logger.ForModule("config")
const (
// http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=docker
DOCKER_RESERVED_PORT = 2375
DOCKER_RESERVED_SSL_PORT = 2376
SSH_PORT = 22
AGENT_INTROSPECTION_PORT = 51678
DEFAULT_CLUSTER_NAME = "default"
)
// Merge merges two config files, preferring the ones on the left. Any nil or
// zero values present in the left that are not present in the right will be
示例8: StartMetricsSession
"github.com/aws/amazon-ecs-agent/agent/utils"
"github.com/aws/amazon-ecs-agent/agent/utils/ttime"
"github.com/aws/aws-sdk-go/aws/credentials"
)
const (
// defaultPublishMetricsInterval is the interval at which utilization
// metrics from stats engine are published to the backend.
defaultPublishMetricsInterval = 20 * time.Second
// The maximum time to wait between heartbeats without disconnecting
heartbeatTimeout = 5 * time.Minute
heartbeatJitter = 3 * time.Minute
)
var log = logger.ForModule("tcs handler")
// StartMetricsSession starts a metric session. It initializes the stats engine
// and invokes StartSession.
func StartMetricsSession(params TelemetrySessionParams) {
disabled, err := params.isTelemetryDisabled()
if err != nil {
log.Warn("Error getting telemetry config", "err", err)
return
}
if !disabled {
statsEngine := stats.NewDockerStatsEngine(params.Cfg)
err := statsEngine.MustInit(params.TaskEngine, params.Cfg.Cluster, params.ContainerInstanceArn)
if err != nil {
log.Warn("Error initializing metrics engine", "err", err)
示例9: DefaultIfBlank
import (
"crypto/rand"
"encoding/binary"
"encoding/hex"
"math"
"math/big"
"reflect"
"strconv"
"strings"
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/utils/ttime"
)
var log = logger.ForModule("util")
func DefaultIfBlank(str string, default_value string) string {
if len(str) == 0 {
return default_value
}
return str
}
func ZeroOrNil(obj interface{}) bool {
value := reflect.ValueOf(obj)
if !value.IsValid() {
return true
}
if obj == nil {
return true
示例10:
"errors"
"runtime"
"time"
"github.com/aws/amazon-ecs-agent/agent/ecs_client/model/ecs"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/docker/docker/pkg/system"
"github.com/aws/amazon-ecs-agent/agent/config"
"github.com/aws/amazon-ecs-agent/agent/ec2"
"github.com/aws/amazon-ecs-agent/agent/httpclient"
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/utils"
)
var log = logger.ForModule("api client")
// ECSClient is an interface over the ECSSDK interface which abstracts away some
// details around constructing the request and reading the response down to the
// parts the agent cares about.
// For example, the ever-present 'Cluster' member is abstracted out so that it
// may be configured once and used throughout transparently.
type ECSClient interface {
// RegisterContainerInstance calculates the appropriate resources, creates
// the default cluster if necessary, and returns the registered
// ContainerInstanceARN if successful.
RegisterContainerInstance() (string, error)
// SubmitTaskStateChange sends a state change and returns an error
// indicating if it was submitted
SubmitTaskStateChange(change TaskStateChange) utils.RetriableError
// SubmitContainerStateChange sends a state change and returns an error
示例11:
// a) Add 'ACSSeqNum' top level field (backwards compatible; technically
// forwards compatible but could cause resource constraint violations)
// b) remove 'DEAD', 'UNKNOWN' state from ever being marshalled (backward and
// forward compatible)
// 3) Add 'Protocol' field to 'portMappings' and 'KnownPortBindings'
// 4) Add 'DockerConfig' struct
// 5) Add 'ImageStates' struct as part of ImageManager
const EcsDataVersion = 5
// Filename in the ECS_DATADIR
const ecsDataFile = "ecs_agent_data.json"
// How frequently to flush to disk
const minSaveInterval = 10 * time.Second
var log = logger.ForModule("statemanager")
// Saveable types should be able to be json serializable and deserializable
// Properly, this should have json.Marshaler/json.Unmarshaler here, but string
// and so on can be marshaled/unmarshaled sanely but don't fit those interfaces.
type Saveable interface{}
// Saver is a type that can be saved
type Saver interface {
Save() error
ForceSave() error
}
// Option functions are functions that may be used as part of constructing a new
// StateManager
type Option func(StateManager)
示例12: StartTerminationHandler
import (
"errors"
"os"
"os/signal"
"syscall"
"time"
"github.com/aws/amazon-ecs-agent/agent/engine"
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/sighandlers/exitcodes"
"github.com/aws/amazon-ecs-agent/agent/statemanager"
"github.com/aws/amazon-ecs-agent/agent/utils"
)
var log = logger.ForModule("TerminationHandler")
func StartTerminationHandler(saver statemanager.Saver, taskEngine engine.TaskEngine) {
signalChannel := make(chan os.Signal, 2)
signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM)
sig := <-signalChannel
log.Debug("Received termination signal", "signal", sig.String())
err := FinalSave(saver, taskEngine)
if err != nil {
log.Crit("Error saving state before final shutdown", "err", err)
// Terminal because it's a sigterm; the user doesn't want it to restart
os.Exit(exitcodes.ExitTerminal)
}
os.Exit(exitcodes.ExitSuccess)
示例13:
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
package dockerstate
import (
"sync"
"github.com/aws/amazon-ecs-agent/agent/api"
"github.com/aws/amazon-ecs-agent/agent/engine/image"
"github.com/aws/amazon-ecs-agent/agent/logger"
)
var log = logger.ForModule("dockerstate")
// dockerTaskEngineState keeps track of all mappings between tasks we know about
// and containers docker runs
// It contains a mutex that can be used to ensure out-of-date state cannot be
// accessed before an update comes and to ensure multiple goroutines can safely
// work with it.
//
// The methods on it will aquire the read lock, but not all aquire the write
// lock (sometimes it is up to the caller). This is because the write lock for
// containers should encapsulate the creation of the resource as well as adding,
// and creating the resource (docker container) is outside the scope of this
// package. This isn't ideal usage and I'm open to this being reworked/improved.
//
// Some information is duplicated in the interest of having efficient lookups
type DockerTaskEngineState struct {
示例14: ValidDependencies
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
package dependencygraph
import (
"strings"
"github.com/aws/amazon-ecs-agent/agent/api"
"github.com/aws/amazon-ecs-agent/agent/logger"
)
var log = logger.ForModule("dependencygraph")
// Because a container may depend on another container being created
// (volumes-from) or running (links) it makes sense to abstract it out
// to each container having dependencies on another container being in any
// perticular state set. For now, these are resolved here and support only
// volume/link (created/run)
// ValidDependencies takes a task and verifies that it is possible to allow all
// containers within it to reach the desired status by proceeding in some order
func ValidDependencies(task *api.Task) bool {
unresolved := make([]*api.Container, len(task.Containers))
resolved := make([]*api.Container, 0, len(task.Containers))
copy(unresolved, task.Containers)
示例15: SetConfig
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
// Package dockerauth handles storing auth configuration information for Docker
// registries
package dockerauth
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/credentialprovider"
"github.com/aws/amazon-ecs-agent/agent/config"
"github.com/aws/amazon-ecs-agent/agent/engine/dockerauth/ecs"
"github.com/aws/amazon-ecs-agent/agent/logger"
docker "github.com/fsouza/go-dockerclient"
)
var log = logger.ForModule("docker auth")
var keyring credentialprovider.DockerKeyring
// SetConfig loads credentials from a config
func SetConfig(conf *config.Config) {
ecs_credentials.SetConfig(conf)
keyring = credentialprovider.NewDockerKeyring()
}
// GetAuthconfig retrieves the correct auth configuration for the given image
func GetAuthconfig(image string) docker.AuthConfiguration {
if keyring == nil {
return docker.AuthConfiguration{}
}
authConfig, ok := keyring.Lookup(image)