Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Flexibility with an executeRaw Function #31

Open
gregpriday opened this issue Aug 17, 2023 · 1 comment
Open

Enhance Flexibility with an executeRaw Function #31

gregpriday opened this issue Aug 17, 2023 · 1 comment

Comments

@gregpriday
Copy link
Contributor

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:

  1. 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.

  1. Utilize AbstractEndpoint: Instead of direct implementation, we can modify the createRequest method in AbstractEndpoint 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.

@hkulekci
Copy link
Owner

Hello @gregpriday, thank you for sharing your opinion. Let's discuss this matter again to determine whether it is necessary for our clients or not. Additionally, we can continue the conversation on Discord of Qdrant if you prefer. I will be available, so please feel free to reach out to me anytime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants