James Hartig created CASSGO-92:
----------------------------------

             Summary: Improve usability for external HostSelectionPolicy
                 Key: CASSGO-92
                 URL: https://issues.apache.org/jira/browse/CASSGO-92
             Project: Apache Cassandra Go driver
          Issue Type: Improvement
          Components: Core
            Reporter: James Hartig
            Assignee: James Hartig


Right now there are several things that make writing an external 
HostSelectionPolicy:
 # No access to context in `ExecutableStatement`
 # Cannot read statement metadata (via prepare)
 # No access to the underlying Statement or Entries
 # No access to the consistency
 # No access to logging
 # There's no executor on the session when `Init(session)` is called and trying 
to query causes a panic

 

There are workarounds for some of these things:
 # Assert `ExecutableStatement` matches `interface \{ Context() context.Context 
}`.
 # No workaround
 # Typecast `Statement()` against `*Query` and `*Batch` but you lose support 
for new/custom types.
 # Same as #3
 # No workaround
 # No workaround

I'd like to start by exposing a `StatementMetadata` method on Session that 
behaves much like `routingKeyInfo` but without a cache. I'll consolidate 
`routingKeyInfo` to use the same code but keep the cache around for that 
internal method. External calls should utilize their own cache if they want to 
cache. We _could_ have `StatementMetadata` do caching but invalidation will be 
hard so leaving it up to the caller means they can control when they want to 
invalidate.

Also, we should fix session initialization to not initialize the 
HostSelectionPolicy until after `executor` is set. But we should document that 
when `Init(session)` is called, there might not be any ready pool and 
`Init(session)` should not block.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to