public virtual void SetUp() { rollbarclient = MockRepository.GenerateStub<IRollbarClient>(); autoMocker = new RhinoAutoMocker<BoardGameGeekBatchUpdateJobService>(); autoMocker.Inject(typeof(IRollbarClient), rollbarclient); autoMocker.Get<IDataContext>() .Expect(mock => mock.GetQueryable<GameDefinition>()) .Return(OrphanGames.AsQueryable()); }
public virtual void SetUp() { rollbarclient = MockRepository.GenerateStub <IRollbarClient>(); autoMocker = new RhinoAutoMocker <BoardGameGeekBatchUpdateJobService>(); autoMocker.Inject(typeof(IRollbarClient), rollbarclient); autoMocker.Get <IDataContext>() .Expect(mock => mock.GetQueryable <GameDefinition>()) .Return(OrphanGames.AsQueryable()); }
public PlayedGameEventHandler( IDataContext dataContext, INemeStatsEventTracker playedGameEventTracker, IAchievementProcessor achievementProcessor, IChampionRecalculator championRecalculator, INemesisRecalculator nemesisRecalculator, IGamingGroupChampionRecalculator gamingGroupChampionRecalculator, IRollbarClient rollbar) : base(dataContext) { _playedGameEventTracker = playedGameEventTracker; _achievementProcessor = achievementProcessor; _championRecalculator = championRecalculator; _nemesisRecalculator = nemesisRecalculator; _gamingGroupChampionRecalculator = gamingGroupChampionRecalculator; _rollbar = rollbar; }
public RollbarClientTests() { Environment.SetEnvironmentVariable("Rollbar:AccessToken", _accessToken); var configurationManager = new ConfigurationManager(new ConfigurationBuilder()); _apiClientMock = new Mock <IApiClient>(); _apiClientMock.Setup(apiClient => apiClient.SetSerializerSettings(It.IsAny <Action <JsonSerializerSettings> >(), It.IsAny <DataFormat>(), It.IsAny <string[]>())).Returns(_apiClientMock.Object); var apiClientFactoryMock = new Mock <IApiClientFactory>(); apiClientFactoryMock.Setup(apiClientFactory => apiClientFactory.Create(It.IsAny <string>())) .Returns(_apiClientMock.Object); _sut = new RollbarClient(apiClientFactoryMock.Object, configurationManager); }
protected virtual async Task InitializeAsync(ILambdaConfigSource envSource, ILambdaContext context) { // read configuration from environment variables DeploymentTier = envSource.Read("TIER"); ModuleName = envSource.Read("MODULE"); _deadLetterQueueUrl = envSource.Read("DEADLETTERQUEUE"); _loggingTopicArn = envSource.Read("LOGGINGTOPIC"); var framework = envSource.Read("LAMBDARUNTIME"); LogInfo($"TIER = {DeploymentTier}"); LogInfo($"MODULE = {ModuleName}"); LogInfo($"DEADLETTERQUEUE = {_deadLetterQueueUrl ?? "NONE"}"); LogInfo($"LOGGINGTOPIC = {_loggingTopicArn ?? "NONE"}"); // read optional git-sha file var gitsha = File.Exists("gitsha.txt") ? File.ReadAllText("gitsha.txt") : null; LogInfo($"GITSHA = {gitsha ?? "NONE"}"); // convert environment variables to lambda parameters _appConfig = new LambdaConfig(new LambdaDictionarySource(await ReadParametersFromEnvironmentVariables())); // initialize rollbar var rollbarAccessToken = _appConfig.ReadText("RollbarToken", defaultValue: null); const string proxy = ""; const string platform = "lambda"; _rollbarClient = RollbarClient.Create(new RollbarConfiguration( // NOTE (2018-08-06, bjorg): the rollbar access token determines the rollbar project // the error report is associated with; when rollbar intergration is disabled, // use the module name instead so the logging recipient can determine the module // the log entry belongs to. rollbarAccessToken ?? ModuleName, proxy, DeploymentTier, platform, framework, gitsha )); _rollbarEnabled = (rollbarAccessToken != null); LogInfo($"ROLLBAR = {(_rollbarEnabled ? "ENABLED" : "DISABLED")}"); }
public BoardGameGeekClient(IApiDownloadService apiDownloadService, IRollbarClient rollbarClient) { _apiDownloadService = apiDownloadService; _rollbar = rollbarClient; }
public BoardGameGeekClient(IApiDownloadService apiDownloadService, IRollbarClient rollbarClient) { _apiDownloadService = apiDownloadService; _rollbar = rollbarClient; }
public BoardGameGeekBatchUpdateJobService(IDataContext dataContext, IBoardGameGeekApiClient boardGameGeekApiClient, IRollbarClient rollbar) : base(rollbar) { _dataContext = dataContext; _boardGameGeekApiClient = boardGameGeekApiClient; }
public BusinessLogicEventBus(BusinessLogicEventsHandlerFactory handlerFactory, IRollbarClient rollbar) { _handlerFactory = handlerFactory; _rollbar = rollbar; }
public AchievementsEventHandler(IDataContext dataContext, IRollbarClient rollbarClient) : base(dataContext) { _rollbarClient = rollbarClient; }
protected BaseJobService(IRollbarClient rollbar) { RollbarClient = rollbar; }
protected BaseJobService(IRollbarClient rollbar) { RollbarClient = rollbar; }
public BusinessLogicEventBus(BusinessLogicEventsHandlerFactory handlerFactory, IRollbarClient rollbar) { _handlerFactory = handlerFactory; _rollbar = rollbar; }
protected virtual async Task InitializeAsync(ILambdaConfigSource envSource, ILambdaContext context) { // read configuration from environment variables DeploymentTier = envSource.Read("TIER"); ModuleName = envSource.Read("MODULE"); _deadLetterQueueUrl = envSource.Read("DEADLETTERQUEUE"); _loggingTopicArn = envSource.Read("LOGGINGTOPIC"); var framework = envSource.Read("LAMBDARUNTIME"); LogInfo($"TIER = {DeploymentTier}"); LogInfo($"MODULE = {ModuleName}"); LogInfo($"DEADLETTERQUEUE = {_deadLetterQueueUrl ?? "NONE"}"); LogInfo($"LOGGINGTOPIC = {_loggingTopicArn ?? "NONE"}"); // read optional git-sha file var gitsha = File.Exists("gitsha.txt") ? File.ReadAllText("gitsha.txt") : null; LogInfo($"GITSHA = {gitsha ?? "NONE"}"); // read module parameter values from parameters file var parameters = await ParseParameters("/", File.ReadAllText("parameters.json")); // create config where environment variables take precedence over those found in the parameter file _appConfig = new LambdaConfig(new LambdaMultiSource(new[] { envSource, new LambdaDictionarySource("", parameters) })); // initialize rollbar var rollbarAccessToken = _appConfig.ReadText("RollbarToken", defaultValue: null); const string proxy = ""; const string platform = "lambda"; _rollbarClient = RollbarClient.Create(new RollbarConfiguration( // NOTE (2018-08-06, bjorg): the rollbar access token determines the rollbar project // the error report is associated with; when rollbar intergration is disabled, // use the module name instead so the logging recipient can determine the module // the log entry belongs to. rollbarAccessToken ?? ModuleName, proxy, DeploymentTier, platform, framework, gitsha )); _rollbarEnabled = (rollbarAccessToken != null); LogInfo($"ROLLBAR = {(_rollbarEnabled ? "ENABLED" : "DISABLED")}"); // local functions async Task <Dictionary <string, string> > ParseParameters(string parameterPrefix, string json) { var functionParameters = JsonConvert.DeserializeObject <Dictionary <string, LambdaFunctionParameter> >(json); var flatten = new Dictionary <string, string>(); await Flatten(functionParameters, parameterPrefix, "STACK_", flatten); return(flatten); // local functions async Task Flatten(Dictionary <string, LambdaFunctionParameter> source, string prefix, string envPrefix, Dictionary <string, string> target) { foreach (var kv in source) { var value = kv.Value.Value; switch (kv.Value.Type) { case LambdaFunctionParameterType.Collection: await Flatten((Dictionary <string, LambdaFunctionParameter>) value, prefix + kv.Key + "/", envPrefix + kv.Key.ToUpperInvariant() + "_", target); break; case LambdaFunctionParameterType.Secret: { var secret = (string)value; var plaintextStream = (await _kmsClient.DecryptAsync(new DecryptRequest { CiphertextBlob = new MemoryStream(Convert.FromBase64String(secret)), EncryptionContext = kv.Value.EncryptionContext })).Plaintext; target.Add(prefix + kv.Key, Encoding.UTF8.GetString(plaintextStream.ToArray())); break; } case LambdaFunctionParameterType.Stack: target.Add(prefix + kv.Key, envSource.Read(envPrefix + kv.Key.ToUpperInvariant())); break; case LambdaFunctionParameterType.Text: target.Add(prefix + kv.Key, (string)value); break; default: throw new NotSupportedException($"unsupported parameter type: '{kv.Value.Type.ToString()}'"); } } } } }
public AchievementProcessor(IDataContext dataContext, IRollbarClient rollbarClient) { _dataContext = dataContext; _rollbarClient = rollbarClient; }
public BoardGameGeekBatchUpdateJobService(IDataContext dataContext, IBoardGameGeekApiClient boardGameGeekApiClient, IRollbarClient rollbar) : base(rollbar) { _dataContext = dataContext; _boardGameGeekApiClient = boardGameGeekApiClient; }