Struct: session.Session

import "../ibm-cos-sdk-go/aws/session"

Overview

A Session provides a central location to create service clients from and store configurations and request handlers for those services.

Sessions are safe to create service clients concurrently, but it is not safe to mutate the Session concurrently.

The Session satisfies the service client's client.ConfigProvider.

Implemented Interfaces

s3crypto.Cipher, client.ConfigNoResolveEndpointProvider, client.ConfigProvider, s3manager.ReadSeekerWriteTo, s3manager.WriterReadFrom

Structure Field Summary collapse

Constructor Functions collapse

Method Summary collapse

Structure Field Details

Config *aws.Config

Handlers request.Handlers

Function Details

func Must(sess *Session, err error) *Session

Must is a helper function to ensure the Session is valid and there was no error when calling a NewSession function.

This helper is intended to be used in variable initialization to load the Session and configuration at startup. Such as:

var sess = session.Must(session.NewSession())


303
304
305
306
307
308
309
// File 'aws/session/session.go', line 303

func Must(sess *Session, err error) *Session { if err != nil { panic(err) } return sess }

Method Details

func (s *Session) ClientConfig(service string, cfgs ...*aws.Config) client.Config

ClientConfig satisfies the client.ConfigProvider interface and is used to configure the service client instances. Passing the Session to the service client's constructor (New) will use this method to configure the client.



645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
// File 'aws/session/session.go', line 645

func (s *Session) ClientConfig(service string, cfgs ...*aws.Config) client.Config { s = s.Copy(cfgs...) resolvedRegion := normalizeRegion(s.Config) region := aws.StringValue(s.Config.Region) resolved, err := s.resolveEndpoint(service, region, resolvedRegion, s.Config) if err != nil { s.Handlers.Validate.PushBack(func(r *request.Request) { if len(r.ClientInfo.Endpoint) != 0 { // Error occurred while resolving endpoint, but the request // being invoked has had an endpoint specified after the client // was created. return } r.Error = err }) } return client.Config{ Config: s.Config, Handlers: s.Handlers, PartitionID: resolved.PartitionID, Endpoint: resolved.URL, SigningRegion: resolved.SigningRegion, SigningNameDerived: resolved.SigningNameDerived, SigningName: resolved.SigningName, ResolvedRegion: resolvedRegion, } }

func (s *Session) ClientConfigNoResolveEndpoint(cfgs ...*aws.Config) client.Config

ClientConfigNoResolveEndpoint is the same as ClientConfig with the exception that the EndpointResolver will not be used to resolve the endpoint. The only endpoint set must come from the aws.Config.Endpoint field.



716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
// File 'aws/session/session.go', line 716

func (s *Session) ClientConfigNoResolveEndpoint(cfgs ...*aws.Config) client.Config { s = s.Copy(cfgs...) resolvedRegion := normalizeRegion(s.Config) var resolved endpoints.ResolvedEndpoint if ep := aws.StringValue(s.Config.Endpoint); len(ep) > 0 { resolved.URL = endpoints.AddScheme(ep, aws.BoolValue(s.Config.DisableSSL)) resolved.SigningRegion = aws.StringValue(s.Config.Region) } return client.Config{ Config: s.Config, Handlers: s.Handlers, Endpoint: resolved.URL, SigningRegion: resolved.SigningRegion, SigningNameDerived: resolved.SigningNameDerived, SigningName: resolved.SigningName, ResolvedRegion: resolvedRegion, } }

func (s *Session) Copy(cfgs ...*aws.Config) *Session

Copy creates and returns a copy of the current Session, copying the config and handlers. If any additional configs are provided they will be merged on top of the Session's copied config.

// Create a copy of the current Session, configured for the us-west-2 region. sess.Copy(&aws.Config{Region: aws.String("us-west-2")})


630
631
632
633
634
635
636
637
638
639
640
// File 'aws/session/session.go', line 630

func (s *Session) Copy(cfgs ...*aws.Config) *Session { newSession := &Session{ Config: s.Config.Copy(cfgs...), Handlers: s.Handlers.Copy(), options: s.options, } initHandlers(newSession) return newSession }