小编Jon*_*bek的帖子

多线程java优化

在我的程序中,我尝试了解如何使用ExecutorService来优化我的程序.出于某种原因,它会在两个Urls上陷入困境.该http://sjsu.edu/https://paypal.com.当它位于这两个上时,它不会继续执行其他URL.

即使两个域的响应速度不够快,其他3个线程是否仍然无法继续?

如何以最佳方式解决这个问题?

public class SequentialPinger {
    public static void main(String args[]) throws Exception {

        String[] hostList = {"http://crunchify.com", "http://yahoo.com",
            "http://www.ebay.com", "http://google.com",
            "http://www.example.co", "https://paypal.com",
            "http://bing.com/", "http://techcrunch.com/",
            "http://mashable.com/", "http://thenextweb.com/",
            "http://wordpress.com/", "http://cphbusiness.dk/",
            "http://example.com/", "http://sjsu.edu/",
            "http://ebay.co.uk/", "http://google.co.uk/",
            "http://www.wikipedia.org/",
            "http://dr.dk", "http://pol.dk", "https://www.google.dk",
            "http://phoronix.com", "http://www.webupd8.org/",
            "https://studypoint-plaul.rhcloud.com/", "http://stackoverflow.com",
            "http://docs.oracle.com", "https://fronter.com",
            "http://imgur.com/", "http://www.imagemagick.org"
        };

        List<CallableImpl> callList = new ArrayList();
        ExecutorService es = Executors.newFixedThreadPool(4);

        for (String url : hostList) {
            CallableImpl callable = new CallableImpl(url);
            callList.add(callable);
        }
        for (CallableImpl callableImpl : callList) {
            System.out.println("Trying …
Run Code Online (Sandbox Code Playgroud)

java performance multithreading

1
推荐指数
1
解决办法
93
查看次数

postgres STRING_AGG() 返回重复项?

我看过一些类似的帖子,请求建议以从查询中获得不同的结果。这可以通过子查询来解决,但我聚合的列image_name是唯一的image_name VARCHAR(40) NOT NULL UNIQUE。我认为这没有必要。

这是spot_images表中的数据

spotdk=# select * from spot_images;
 id | user_id | spot_id |              image_name              
----+---------+---------+--------------------------------------
  1 |       1 |       1 | 81198013-e8f8-4baa-aece-6fbda15a0498
  2 |       1 |       1 | 21b78e4e-f2e4-4d66-961f-83e5c28d69c5
  3 |       1 |       1 | 59834585-8c49-4cdf-95e4-38c437acb3c1
  4 |       1 |       1 | 0a42c962-2445-4b3b-97a6-325d344fda4a
(4 rows)
Run Code Online (Sandbox Code Playgroud)
spotdk=# select * from spot_images;
 id | user_id | spot_id |              image_name              
----+---------+---------+--------------------------------------
  1 |       1 |       1 | 81198013-e8f8-4baa-aece-6fbda15a0498
  2 |       1 |       1 | 21b78e4e-f2e4-4d66-961f-83e5c28d69c5 …
Run Code Online (Sandbox Code Playgroud)

sql postgresql join group-by average

1
推荐指数
1
解决办法
2208
查看次数

如何使用续集特定错误?

你如何导入续集错误?我想使用特定的错误,例如SequelizeUniqueConstraintError)错误处理。

try {
  query...
} catch(e){
  if (e instanceof SequelizeUniqueConstraintError) { 
    next(new ResourceError(e.toString(), 401))
  } else {
    next(new ResourceError(e.toString(), 500))
  }
}
Run Code Online (Sandbox Code Playgroud)

我得到了SequelizeUniqueConstraintError is not defined,但我似乎无法浏览 sequelize 实例以找到任何错误类?

exception node.js sequelize.js

0
推荐指数
1
解决办法
219
查看次数

nestjs 在简单的提供程序类中使用 ConfigService

是否可以访问由简单提供者类中的配置工厂制作的嵌套配置?

喜欢:

/*Can't use ConfigService because there is no way of injecting it seemingly*/
export const databaseProviders = [
  {
    provide: 'SEQUELIZE',
    useFactory: async () => {
      const sequelize = new Sequelize({
        host: ConfigService.get<string>('pg.host'),
        port: ConfigService.get<number>('pg.port'),
        dialect: 'postgres',
        username: ConfigService.get<string>('pg.username'),
        password: ConfigService.get<string>('pg.password'),
        database: ConfigService.get<string>('pg.database')
      });
      sequelize.addModels([
         models...
      ]);
      await sequelize.sync(
        process.env.NODE_ENV === 'developent' && {
          force: true
        }
      );
      return sequelize;
    }
  }
];
Run Code Online (Sandbox Code Playgroud)

config/configuration.ts

export default () => ({
  pg: {
    host: 'localhost',
    port: 5432,
    username: process.env.NODE_ENV logic...
    password: …
Run Code Online (Sandbox Code Playgroud)

config typescript nestjs

0
推荐指数
1
解决办法
868
查看次数