-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker Compose Service Connection for Weaviate
- Loading branch information
1 parent
06e3a1f
commit 6983a39
Showing
4 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...er/compose/service/connection/weaviate/WeaviateDockerComposeConnectionDetailsFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2023 - 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.ai.docker.compose.service.connection.weaviate; | ||
|
||
import org.springframework.ai.autoconfigure.vectorstore.weaviate.WeaviateConnectionDetails; | ||
import org.springframework.boot.docker.compose.core.RunningService; | ||
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory; | ||
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionSource; | ||
|
||
/** | ||
* @author Eddú Meléndez | ||
*/ | ||
class WeaviateDockerComposeConnectionDetailsFactory | ||
extends DockerComposeConnectionDetailsFactory<WeaviateConnectionDetails> { | ||
|
||
private static final String[] WEAVIATE_CONTAINER_NAMES = { "semitechnologies/weaviate", | ||
"cr.weaviate.io/semitechnologies/weaviate" }; | ||
|
||
private static final int WEAVIATE_PORT = 8080; | ||
|
||
protected WeaviateDockerComposeConnectionDetailsFactory() { | ||
super(WEAVIATE_CONTAINER_NAMES); | ||
} | ||
|
||
@Override | ||
protected WeaviateConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) { | ||
return new WeaviateDockerComposeConnectionDetails(source.getRunningService()); | ||
} | ||
|
||
/** | ||
* {@link WeaviateConnectionDetails} backed by a {@code Weaviate} | ||
* {@link RunningService}. | ||
*/ | ||
static class WeaviateDockerComposeConnectionDetails extends DockerComposeConnectionDetails | ||
implements WeaviateConnectionDetails { | ||
|
||
private final String host; | ||
|
||
WeaviateDockerComposeConnectionDetails(RunningService service) { | ||
super(service); | ||
this.host = service.host() + ":" + service.ports().get(WEAVIATE_PORT); | ||
} | ||
|
||
@Override | ||
public String getHost() { | ||
return this.host; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...mpose/service/connection/weaviate/WeaviateDockerComposeConnectionDetailsFactoryTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.springframework.ai.docker.compose.service.connection.weaviate; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.ai.autoconfigure.vectorstore.weaviate.WeaviateConnectionDetails; | ||
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class WeaviateDockerComposeConnectionDetailsFactoryTests extends AbstractDockerComposeIntegrationTests { | ||
|
||
WeaviateDockerComposeConnectionDetailsFactoryTests() { | ||
super("weaviate-compose.yaml", DockerImageName.parse("semitechnologies/weaviate")); | ||
} | ||
|
||
@Test | ||
void runCreatesConnectionDetails() { | ||
WeaviateConnectionDetails connectionDetails = run(WeaviateConnectionDetails.class); | ||
assertThat(connectionDetails.getHost()).isNotNull(); | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...s/org/springframework/ai/docker/compose/service/connection/weaviate/weaviate-compose.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
services: | ||
weaviate: | ||
image: '{imageName}' | ||
ports: | ||
- '8080' |