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

Address translation #624

Merged
merged 57 commits into from
Apr 11, 2024
Merged

Conversation

dmitrii-ubskii
Copy link
Member

@dmitrii-ubskii dmitrii-ubskii commented Apr 4, 2024

Usage and product changes

We allow the user to provide a translation map from the advertised server addresses (now treated as generic server names) to the actual addresses the driver shall use to connect to the cloud instances. We require the user to provide the full mapping.

Example usage:

Python:

with TypeDB.cloud_driver({
            "0.deployment-UUID.cloud.typedb.com:1729": "localhost:11729",
            "1.deployment-UUID.cloud.typedb.com:1729": "localhost:21729",
            "2.deployment-UUID.cloud.typedb.com:1729": "localhost:31729"
        }, credential) as driver:
    pass

Rust:

Connection::new_cloud_with_translation(                                                        
    [                                                                                          
        ("0.deployment-UUID.cloud.typedb.com:1729", "localhost:11729"),
        ("1.deployment-UUID.cloud.typedb.com:1729", "localhost:21729"),
        ("2.deployment-UUID.cloud.typedb.com:1729", "localhost:31729"),
    ].into(),                                                                                  
    credential                                                                                   
)                                                                                              

@typedb-bot
Copy link
Member

PR Review Checklist

Do not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed.


Trivial Change

  • This change is trivial and does not require a code or architecture review.

Code

  • Packages, classes, and methods have a single domain of responsibility.
  • Packages, classes, and methods are grouped into cohesive and consistent domain model.
  • The code is canonical and the minimum required to achieve the goal.
  • Modules, libraries, and APIs are easy to use, robust (foolproof and not errorprone), and tested.
  • Logic and naming has clear narrative that communicates the accurate intent and responsibility of each module (e.g. method, class, etc.).
  • The code is algorithmically efficient and scalable for the whole application.

Architecture

  • Any required refactoring is completed, and the architecture does not introduce technical debt incidentally.
  • Any required build and release automations are updated and/or implemented.
  • Any new components follows a consistent style with respect to the pre-existing codebase.
  • The architecture intuitively reflects the application domain, and is easy to understand.
  • The architecture has a well-defined hierarchy of encapsulated components.
  • The architecture is extensible and scalable.

@dmitrii-ubskii dmitrii-ubskii force-pushed the address-mapping branch 4 times, most recently from d23e2dd to af35581 Compare April 4, 2024 15:30
@dmitrii-ubskii dmitrii-ubskii changed the title Address mapping Address translation Apr 8, 2024
Comment on lines -275 to +276
test-python-integration-core:
test-python-integration:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unified integration tests across languages.

Comment on lines -86 to +89
* @param addresses The address(es) of the TypeDB server(s)
* @param addresses The address(es) of the TypeDB server(s) or translation map from addresses
* received from the TypeDB server(s) to addresses to be used by the driver for connection
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constructor overloads don't seem to get separate docs generated.

Comment on lines -33 to +34
Driver Driver::coreDriver(const std::string& coreAddress) {
auto p = _native::connection_open_core(coreAddress.c_str());
Driver Driver::coreDriver(const std::string& address) {
auto p = _native::connection_open_core(address.c_str());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bring in line with declaration.

Comment on lines -73 to +74
* @param addresses The address(es) of the TypeDB server(s)
* @param addresses The address(es) of the TypeDB server(s) or translation map from addresses
* received from the TypeDB server(s) to addresses to be used by the driver for connection
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as C++, separate docs for overloaded ctors aren't generated.

Comment on lines +81 to +82
elif isinstance(addresses, Mapping):
return _Driver(dict(addresses), credential)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Mapping is an Iterable, but not vice versa, so this check must come first.

@dmitrii-ubskii dmitrii-ubskii marked this pull request as ready for review April 11, 2024 11:37
@dmitrii-ubskii dmitrii-ubskii modified the milestones: 2.27.0, 2.28.0 Apr 11, 2024
@dmitrii-ubskii dmitrii-ubskii merged commit dbc7be3 into typedb:development Apr 11, 2024
21 checks passed
@dmitrii-ubskii dmitrii-ubskii deleted the address-mapping branch April 15, 2024 09:52
dmitrii-ubskii added a commit to typedb/typedb-console that referenced this pull request Apr 17, 2024
## Usage and product changes

We allow connection to the cloud servers using an address translation
mapping (cf. typedb/typedb-driver#624). This is
useful when the route from the user to the servers differs from the
route the servers are configured with (e.g. connection to public-facing
servers from an internal network).

Example usage: 
```bash
console \
    --cloud=typedb1.domain.com:1729=typedb.local:11729,typedb2.domain.com:1729=typedb.local:21729 \
    --username=<user> --password=<password>
```
or:
```bash
console \
    --cloud=typedb1.domain.com:1729=typedb.local:11729 \
    --cloud=typedb2.domain.com:1729=typedb.local:21729 \
    --username=<user> --password=<password>
```

Note: we currently require that the user provides translation for the
addresses of _all_ nodes in the Cloud deployment.

## Implementation

We also update the license headers and file from AGPL to MPL 2.0.
typedb-bot pushed a commit to typedb/typedb-studio that referenced this pull request May 7, 2024
## Usage and product changes

We introduce a way to provide address translation when attempting to
connect to cloud servers (cf.
typedb/typedb-driver#624). This is useful when
the route from the user to the servers differs from the route the
servers are configured with (e.g. connection to public-facing servers
from an internal network).

Note: we currently require that the user provides translation for the
addresses of _all_ nodes in the Cloud deployment.

<img width="532"
src="https://github.com/vaticle/typedb-studio/assets/18616863/74859fbd-de4f-4844-b1e6-f3507dc364b7">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants