Open
Description
In case of future updates and features from Qdrant, we should increase the adaptability of our library. With this proposed change, as soon as Qdrant introduces new features, users of this library can instantly integrate and utilize them without having to wait for explicit support in this package.
I'm suggesting two potential paths:
- Direct Implementation in Qdrant Client: We can add an
executeRaw
function to the main Qdrant client class. Here's a draft of that function:
public function executeRaw(string $method, string $uri, array $body = []): ResponseInterface
{
$httpFactory = new HttpFactory();
$request = $httpFactory->createRequest($method, $uri);
if ($body) {
try {
$request = $request->withBody(
$httpFactory->createStream(json_encode($body, JSON_THROW_ON_ERROR))
);
} catch (\JsonException $e) {
throw new InvalidArgumentException('Json parse error!');
}
}
return $this->client->execute($request);
}
However, this approach does introduce some code redundancy.
- Utilize
AbstractEndpoint
: Instead of direct implementation, we can modify thecreateRequest
method inAbstractEndpoint
to be public and static. This way, we centralize the request creation process.
public static function createRequest(string $method, string $uri, array $body = []): RequestInterface
{
//... [code]
}
Given this modification, the executeRaw
function within the main client becomes:
public function executeRaw(string $method, string $uri, array $body = []): ResponseInterface
{
$request = AbstractEndpoint::createRequest($method, $uri, $body);
return $this->client->execute($request);
}
@hkulekci, which approach aligns more with our vision for the library? Once we decide, I'll be happy to draft a PR for review.
Metadata
Assignees
Labels
No labels