示例#1
0
        public CockroachDbPlugin(IServer server) : base(server)
        {
            var config = SpeedDateConfig.GetPluginConfig <CockroachDbConfig>();

            try
            {
                var connStringBuilder = new NpgsqlConnectionStringBuilder
                {
                    Host     = config.Host,
                    Port     = config.Port,
                    Username = config.Username,
                    Password = config.Password,
                    Database = config.Database
                };

                var connectionString = CommandLineArgs.IsProvided(CommandLineArgs.Names.DbConnectionString)
                    ? CommandLineArgs.DbConnectionString
                    : connStringBuilder.ConnectionString;

                if (config.CheckConnectionOnStartup)
                {
                    using (var con = new NpgsqlConnection(connectionString))
                    {
                        con.Open();
                    }
                }

                AuthDatabase     = new AuthDbCockroachDb(connectionString);
                ProfilesDatabase = new ProfilesDbCockroachDb(connectionString);
            }
            catch
            {
                Logs.Error("Failed to connect to database");
                throw;
            }
        }
示例#2
0
 public override void DoAwake(ServerConfigInfo info)
 {
     base.DoAwake(info);
     _authDb     = new AuthDbLdb(new LiteDatabase(@"auth.db"));
     _profilesDb = new ProfilesDatabaseLdb(new LiteDatabase(@"profiles.db"));
 }