Skip to content

Commit

Permalink
refactor: drop opensearch and pgroonga support (#172)
Browse files Browse the repository at this point in the history
* refactor(backend): drop opensearch support

* update lockfile

* update changelog

* refactor: drop pgroonga support

---------

Co-authored-by: Esurio <[email protected]>
  • Loading branch information
1673beta and Esurio authored Sep 12, 2024
1 parent 8d09840 commit 212368d
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 180 deletions.
13 changes: 0 additions & 13 deletions .config/docker_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,6 @@ redis:
# index: ''
# scope: local

# ┌───────────────────────────┐
#───┘ OpenSearch configuration └─────────────────────────────

# You can use OpenSearch when you enabled AdvancedSearch.

#opensearch:
# host: opensearch
# port: 9200
# user: 'admin'
# pass: 'opensearch-adminpassword' #強めのパスワードじゃないと怒られる
# ssl: false
# index: 'instancename' #なんでもいい

# ┌───────────────┐
#───┘ ID generation └───────────────────────────────────────────

Expand Down
16 changes: 0 additions & 16 deletions .config/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ dbReplications: false
# user:
# pass:

# You can use PGroonga when enabled.
#pgroonga: false

# ┌─────────────────────┐
#───┘ Redis configuration └─────────────────────────────────────

Expand Down Expand Up @@ -190,19 +187,6 @@ redis:
# scope: local


# ┌───────────────────────────┐
#───┘ OpenSearch configuration └─────────────────────────────

# You can use OpenSearch when you enabled AdvancedSearch.

#opensearch:
# host: localhost
# port: 9200
# user: 'admin'
# pass: 'opensearch-adminpassword' #強めのパスワードじゃないと怒られる
# ssl: false
# index: 'instancename' #なんでもいい

# ┌───────────────┐
#───┘ ID generation └───────────────────────────────────────────

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG_engawa.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- fix: 設定画面でリロードすべきところでリロードしない問題

### Server
-
- Breaking: OpenSearchを利用不可に

### Misc

Expand Down
36 changes: 0 additions & 36 deletions compose.local-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,3 @@ services:
# - .config/meilisearch.env
# volumes:
# - ./meili_data:/meili_data

# opensearchとopensearch-dashboardsのdockerfileは実装時の最新版の辞書なので適宜書き換えてください
# opensearch:
# build: ./opensearch
# environment:
# - "server.ssl.enabled:false"
# - "discovery.type=single-node"
# - "OPENSEARCH_INITIAL_ADMIN_PASSWORD=opensearch-adminpassword" #強めのパスワードじゃないと怒られる
# - "plugins.security.disabled=true"
# ulimits:
# memlock:
# soft: -1 # Set memlock to unlimited (no soft or hard limit)
# hard: -1
# nofile:
# soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
# hard: 65536
# volumes:
# - ./os-data:/usr/share/opensearch/data
# networks:
# - internal_network
# - external_network

#OpenSearchのダッシュボードを見る場合に必要
# opensearch-dashboards:
# build: ./opensearch-dashboards
# ports:
# - 5601:5601
# links:
# - opensearch
# expose:
# - '5601'
# environment:
# OPENSEARCH_HOSTS: 'http://opensearch:9200'
# networks:
# - internal_network
# - external_network
1 change: 0 additions & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
"@nestjs/common": "10.3.10",
"@nestjs/core": "10.3.10",
"@nestjs/testing": "10.3.10",
"@opensearch-project/opensearch": "^2.7.0",
"@peertube/http-signature": "1.7.0",
"@sentry/node": "8.20.0",
"@sentry/profiling-node": "8.20.0",
Expand Down
28 changes: 2 additions & 26 deletions packages/backend/src/GlobalModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Global, Inject, Module } from '@nestjs/common';
import * as Redis from 'ioredis';
import { DataSource } from 'typeorm';
import { MeiliSearch } from 'meilisearch';
import { Client as OpenSearch } from '@opensearch-project/opensearch';
import { Logging } from '@google-cloud/logging';
import { DI } from './di-symbols.js';
import { Config, loadConfig } from './config.js';
Expand Down Expand Up @@ -46,29 +45,6 @@ const $meilisearch: Provider = {
inject: [DI.config],
};

const $opensearch: Provider = {
provide: DI.opensearch,
useFactory: (config: Config) => {
if (config.opensearch) {
return new OpenSearch({
nodes: {
url: new URL(`${config.opensearch.ssl ? 'https' : 'http'}://${config.opensearch.host}:${config.opensearch.port}`),
ssl: {
rejectUnauthorized: config.opensearch.rejectUnauthorized,
},
},
auth: {
username: config.opensearch.user,
password: config.opensearch.pass,
},
});
} else {
return null;
}
},
inject: [DI.config],
};

const $cloudLogging: Provider = {
provide: DI.cloudLogging,
useFactory: (config: Config) => {
Expand Down Expand Up @@ -133,8 +109,8 @@ const $redisForJobQueue: Provider = {
@Global()
@Module({
imports: [RepositoryModule],
providers: [$config, $db, $meilisearch, $opensearch, $cloudLogging, $redis, $redisForPub, $redisForSub, $redisForTimelines, $redisForJobQueue],
exports: [$config, $db, $meilisearch, $opensearch, $cloudLogging, $redis, $redisForPub, $redisForSub, $redisForTimelines, $redisForJobQueue, RepositoryModule],
providers: [$config, $db, $meilisearch, $cloudLogging, $redis, $redisForPub, $redisForSub, $redisForTimelines, $redisForJobQueue],
exports: [$config, $db, $meilisearch, $cloudLogging, $redis, $redisForPub, $redisForSub, $redisForTimelines, $redisForJobQueue, RepositoryModule],
})
export class GlobalModule implements OnApplicationShutdown {
constructor(
Expand Down
22 changes: 0 additions & 22 deletions packages/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type Source = {
user: string;
pass: string;
}[];
pgroonga?: boolean;
redis: RedisOptionsSource;
redisForPubsub?: RedisOptionsSource;
redisForJobQueue?: RedisOptionsSource;
Expand All @@ -58,15 +57,6 @@ type Source = {
index: string;
scope?: 'local' | 'global' | string[];
};
opensearch?: {
host: string;
port: string;
user: string;
pass: string;
ssl?: boolean;
rejectUnauthorized?: boolean;
index: string;
} | undefined;
sentryForBackend?: { options: Partial<Sentry.NodeOptions>; enableNodeProfiling: boolean; };
sentryForFrontend?: { options: Partial<Sentry.NodeOptions> };

Expand Down Expand Up @@ -140,7 +130,6 @@ export type Config = {
user: string;
pass: string;
}[] | undefined;
pgroonga: boolean | undefined;
meilisearch: {
host: string;
port: string;
Expand All @@ -149,15 +138,6 @@ export type Config = {
index: string;
scope?: 'local' | 'global' | string[];
} | undefined;
opensearch: {
host: string;
port: string;
user: string;
pass: string;
ssl?: boolean;
rejectUnauthorized?: boolean;
index: string;
} | undefined;
proxy: string | undefined;
proxySmtp: string | undefined;
proxyBypassHosts: string[] | undefined;
Expand Down Expand Up @@ -284,9 +264,7 @@ export function loadConfig(): Config {
db: { ...config.db, db: dbDb, user: dbUser, pass: dbPass },
dbReplications: config.dbReplications,
dbSlaves: config.dbSlaves,
pgroonga: config.pgroonga,
meilisearch: config.meilisearch,
opensearch: config.opensearch,
redis,
redisForPubsub: config.redisForPubsub ? convertRedisOptions(config.redisForPubsub, host) : redis,
redisForJobQueue: config.redisForJobQueue ? convertRedisOptions(config.redisForJobQueue, host) : redis,
Expand Down
5 changes: 0 additions & 5 deletions packages/backend/src/core/SearchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ export class SearchService {
}

/**
* if (this.config.pgroonga) {
* query.andWhere('note.text &@~ :q', { q: `%${sqlLikeEscape(q)}%` });
*} else {
* query.andWhere('note.text ILIKE :q', { q: `%${sqlLikeEscape(q)}%` });
*}
* TODO: PGroongaの統合
*/

Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/di-symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const DI = {
config: Symbol('config'),
db: Symbol('db'),
meilisearch: Symbol('meilisearch'),
opensearch: Symbol('opensearch'),
cloudLogging: Symbol('cloudLogging'),
redis: Symbol('redis'),
redisForPub: Symbol('redisForPub'),
Expand Down
18 changes: 0 additions & 18 deletions packages/backend/src/server/web/ClientServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,24 +429,6 @@ export class ClientServerService {
return await reply.sendFile('/robots.txt', staticAssets);
});

// OpenSearch XML
fastify.get('/opensearch.xml', async (request, reply) => {
const meta = await this.metaService.fetch();

const name = meta.name ?? 'CherryPick';
let content = '';
content += '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">';
content += `<ShortName>${name}</ShortName>`;
content += `<Description>${name} Search</Description>`;
content += '<InputEncoding>UTF-8</InputEncoding>';
content += `<Image width="16" height="16" type="image/x-icon">${this.config.url}/favicon.ico</Image>`;
content += `<Url type="text/html" template="${this.config.url}/search?q={searchTerms}"/>`;
content += '</OpenSearchDescription>';

reply.header('Content-Type', 'application/opensearchdescription+xml');
return await reply.send(content);
});

//#endregion

const renderBase = async (reply: FastifyReply, data: { [key: string]: any } = {}) => {
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/server/web/views/base.pug
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ html
link(rel='icon' href= icon || '/favicon.ico')
link(rel='apple-touch-icon' href= appleTouchIcon || '/apple-touch-icon.png')
link(rel='manifest' href='/manifest.json')
link(rel='search' type='application/opensearchdescription+xml' title=(title || "CherryPick") href=`${url}/opensearch.xml`)
link(rel='prefetch' href=serverErrorImageUrl)
link(rel='prefetch' href=infoImageUrl)
link(rel='prefetch' href=notFoundImageUrl)
Expand Down
1 change: 0 additions & 1 deletion packages/backend/test/e2e/fetch-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ describe('Webリソース', () => {
{ path: '/flush', type: HTML },
{ path: '/robots.txt', type: 'text/plain; charset=UTF-8' },
{ path: '/favicon.ico', type: 'image/vnd.microsoft.icon' },
{ path: '/opensearch.xml', type: 'application/opensearchdescription+xml' },
{ path: '/apple-touch-icon.png', type: 'image/png' },
{ path: '/twemoji/2764.svg', type: 'image/svg+xml' },
{ path: '/twemoji/2764-fe0f-200d-1f525.svg', type: 'image/svg+xml' },
Expand Down
Loading

0 comments on commit 212368d

Please sign in to comment.