Amazon web services AWS SDK是否自动处理会话到期?

Amazon web services AWS SDK是否自动处理会话到期?,amazon-web-services,go,aws-sdk,Amazon Web Services,Go,Aws Sdk,我正在编写一个客户端,以从RabbitMQ获取连续消息,并推送到AWS SQS服务。但是我不确定会话是否过期,如果会话过期,我们需要重新创建会话还是AWS SDK自动处理会话 log.Printf("PPU Message Broker: Pushing messages to SQS") sess, err := session.NewSession(&aws.Config{ Region: aws.String("us-

我正在编写一个客户端,以从RabbitMQ获取连续消息,并推送到AWS SQS服务。但是我不确定会话是否过期,如果会话过期,我们需要重新创建会话还是AWS SDK自动处理会话

log.Printf("PPU Message Broker: Pushing messages to SQS")
    sess, err := session.NewSession(&aws.Config{
        Region:      aws.String("us-east-1"),
        //Credentials: credentials.NewSharedCredentials("", "sqs_user"),
    })
    _, err = sess.Config.Credentials.Get()
    if err != nil {
        log.Fatalf("PPU Message Broker: Credentails Failed")
    }
    svc := sqs.New(sess)    
    result, err := svc.SendMessage(&sqs.SendMessageInput{
        MessageBody:    aws.String(string(data)),
        MessageGroupId: aws.String("TestGroup"),
        QueueUrl:       &qURL,
    })
最新答复:

刚刚注意到问题是关于AWS SDK for Go的

从AWS SDK for Go文档:

原始答复:

来自AWS Javascript SDK文档


会话过期有默认配置,但您可以指定您的配置:

除了NewSession,您还可以使用创建会话 带有选项的新闻会话。此功能允许您控制和 重写如何通过代码而不是 仅由环境变量驱动

如果要提供配置文件,请使用NewSessionWithOptions

在Options对象内部,有一个用于更改默认过期时间的属性,默认为15分钟:

//当SDK的共享配置配置为承担此角色时 选项 //可以提供以设置STS凭据的到期期限。 //如果未按照中的说明进行设置,则默认为15分钟 //假设提供者。 假设教育时间。持续时间

func (*Credentials) Get

func (c *Credentials) Get() (Value, error)

Get returns the credentials value, or error if the credentials Value failed to be retrieved.

Will return the cached credentials Value if it has not expired. If the credentials Value has expired the Provider's Retrieve() will be called to refresh the credentials.

If Credentials.Expire() was called the credentials Value will be force expired, and the next call to Get() will cause them to be refreshed. 
get(callback) ⇒ void

Gets the existing credentials, refreshing them if they are not yet loaded or have expired. Users should call this method before using refresh(), as this will not attempt to reload credentials when they are already loaded into the object.