func NewRepositoryLocator(config configuration.ReadWriter, gatewaysByName map[string]net.Gateway) (loc RepositoryLocator) { strategy := strategy.NewEndpointStrategy(config.ApiVersion()) authGateway := gatewaysByName["auth"] cloudControllerGateway := gatewaysByName["cloud-controller"] uaaGateway := gatewaysByName["uaa"] loc.authRepo = NewUAAAuthenticationRepository(authGateway, config) // ensure gateway refreshers are set before passing them by value to repositories cloudControllerGateway.SetTokenRefresher(loc.authRepo) uaaGateway.SetTokenRefresher(loc.authRepo) tlsConfig := net.NewTLSConfig([]tls.Certificate{}, config.IsSSLDisabled()) loggregatorConsumer := consumer.New(config.LoggregatorEndpoint(), tlsConfig, nil) loc.appBitsRepo = NewCloudControllerApplicationBitsRepository(config, cloudControllerGateway, app_files.ApplicationZipper{}) loc.appEventsRepo = NewCloudControllerAppEventsRepository(config, cloudControllerGateway, strategy) loc.appFilesRepo = NewCloudControllerAppFilesRepository(config, cloudControllerGateway) loc.appRepo = NewCloudControllerApplicationRepository(config, cloudControllerGateway) loc.appSummaryRepo = NewCloudControllerAppSummaryRepository(config, cloudControllerGateway) loc.appInstancesRepo = NewCloudControllerAppInstancesRepository(config, cloudControllerGateway) loc.authTokenRepo = NewCloudControllerServiceAuthTokenRepository(config, cloudControllerGateway) loc.curlRepo = NewCloudControllerCurlRepository(config, cloudControllerGateway) loc.domainRepo = NewCloudControllerDomainRepository(config, cloudControllerGateway, strategy) loc.endpointRepo = NewEndpointRepository(config, cloudControllerGateway) loc.logsRepo = NewLoggregatorLogsRepository(config, loggregatorConsumer) loc.organizationRepo = NewCloudControllerOrganizationRepository(config, cloudControllerGateway) loc.passwordRepo = NewCloudControllerPasswordRepository(config, uaaGateway) loc.quotaRepo = NewCloudControllerQuotaRepository(config, cloudControllerGateway) loc.routeRepo = NewCloudControllerRouteRepository(config, cloudControllerGateway, loc.domainRepo) loc.stackRepo = NewCloudControllerStackRepository(config, cloudControllerGateway) loc.serviceRepo = NewCloudControllerServiceRepository(config, cloudControllerGateway) loc.serviceBindingRepo = NewCloudControllerServiceBindingRepository(config, cloudControllerGateway) loc.serviceBrokerRepo = NewCloudControllerServiceBrokerRepository(config, cloudControllerGateway) loc.serviceSummaryRepo = NewCloudControllerServiceSummaryRepository(config, cloudControllerGateway) loc.spaceRepo = NewCloudControllerSpaceRepository(config, cloudControllerGateway) loc.userProvidedServiceInstanceRepo = NewCCUserProvidedServiceInstanceRepository(config, cloudControllerGateway) loc.userRepo = NewCloudControllerUserRepository(config, uaaGateway, cloudControllerGateway) loc.buildpackRepo = NewCloudControllerBuildpackRepository(config, cloudControllerGateway) loc.buildpackBitsRepo = NewCloudControllerBuildpackBitsRepository(config, cloudControllerGateway, app_files.ApplicationZipper{}) return }
func (repo LoggregatorLogsRepository) connectToWebsocket(location string, onConnect func(), outputChan chan *logmessage.Message, stopLoggingChan chan bool, printTimeBuffer time.Duration) (err error) { trace.Logger.Printf("\n%s %s\n", terminal.HeaderColor("CONNECTING TO WEBSOCKET:"), location) inputChan := make(chan *logmessage.Message, LogBufferSize) messageQueue := NewSortedMessageQueue(printTimeBuffer, time.Now) wsConfig, err := websocket.NewConfig(location, "http://localhost") if err != nil { return } wsConfig.Header.Add("Authorization", repo.config.AccessToken()) wsConfig.TlsConfig = net.NewTLSConfig(repo.TrustedCerts, repo.config.IsSSLDisabled()) ws, err := websocket.DialConfig(wsConfig) if err != nil { err = net.WrapSSLErrors(location, err) return } defer func() { ws.Close() repo.drainRemainingMessages(messageQueue, inputChan, outputChan) }() onConnect() go repo.sendKeepAlive(ws) go func() { defer close(inputChan) repo.listenForMessages(ws, inputChan) }() repo.processMessages(messageQueue, inputChan, outputChan, stopLoggingChan) return }