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

Meta: Schema registry #43

Closed
4 tasks
Tracked by #40
tillrohrmann opened this issue Jan 18, 2023 · 2 comments · Fixed by #186 or #559
Closed
4 tasks
Tracked by #40

Meta: Schema registry #43

tillrohrmann opened this issue Jan 18, 2023 · 2 comments · Fixed by #186 or #559
Labels

Comments

@tillrohrmann
Copy link
Contributor

tillrohrmann commented Jan 18, 2023

In order to store discovered service information (e.g. service descriptors) and to make this information accessible to the Restate cluster, we need a service registry that manages this information.

Tasks

Preview Give feedback
@tillrohrmann tillrohrmann added the needs-refinement Issues that need further investigation label Jan 18, 2023
@tillrohrmann tillrohrmann added this to the 1A milestone Jan 18, 2023
@tillrohrmann tillrohrmann changed the title Service registry Meta: Service registry Jan 19, 2023
@tillrohrmann tillrohrmann self-assigned this Mar 14, 2023
@slinkydeveloper slinkydeveloper removed the needs-refinement Issues that need further investigation label Mar 22, 2023
@slinkydeveloper slinkydeveloper changed the title Meta: Service registry Meta: Schema registry Apr 5, 2023
@slinkydeveloper
Copy link
Contributor

I moved this back to Todo because we have a primitive version of the Schema registry, but we need to reiterate on it to support all the meta functionalities. Also see #227 (comment).

One of the main concerns with the current approach is keeping consistency across different data structures, in particular with #226 in mind. It would be nice to have a single point where we update these data structures, making easy to guarantee consistency when reading metadata.

One idea I have in mind to achieve that is to define interfaces for all the read access patterns every component needs, something like:

// --- Key extractor and key expander

#[cfg(feature = "key_extractor")]
pub trait KeyExtractorResolver {
    fn resolve_key_extractor(
        &self,
        service_name: impl AsRef<str>,
        method_name: impl AsRef<str>
    ) -> Option<MethodKeyExtractor<'_>>;
}

#[cfg(feature = "key_expander")]
pub trait KeyExpanderResolver {
    fn resolve_key_expander(
        &self,
        service_name: impl AsRef<str>,
    ) -> Option<&ServiceKeyExpander>;
}

// --- Json mapper

#[cfg(feature = "json_mapper")]
pub trait JsonMapperResolver {
    fn resolve_json_mapper(
        &self,
        service_name: impl AsRef<str>,
        method_name: impl AsRef<str>
    ) -> Option<(/* request */ JsonMapper, /* response */ JsonMapper)>;
}

// --- Endpoint resolver

#[cfg(feature = "endpoint_meta")]
pub trait EndpointMetadataResolver {
    fn resolve_latest_endpoint(
        &self,
        service_name: impl AsRef<str>,
    ) -> Option<EndpointMetadata>;

    fn resolve_endpoint(
        &self,
        endpoint_id: &EndpointId,
    ) -> Option<EndpointMetadata>;
}

// --- Reflections resolver

#[cfg(feature = "proto_symbol")]
pub trait ProtoSymbolResolver {
    fn list_services(&self) -> &[&str];

    fn get_file_descriptor_by_symbol_name(&self, symbol: &str) -> Option<FileDescriptor>;

    fn get_file_descriptor(&self, file_name: &str) -> Option<FileDescriptor>;
}

Keep in mind that some of these interfaces already exists, in more or less a similar shape. Once we have those in place, for the first version of Restate we just need a struct that contains all the implementations of these interfaces:

struct MetadataRegistry {
  // Single tree of metadata behind an ArcSwap
}

#[cfg(feature = "key_extractor")]
impl KeyExtractorResolver for MetadataRegistry {}
// etc...

By feature-gating interfaces and implementations, we make sure that individual crates will consume only the part of the schema registry they need. This allows us in future to easily split the MetadataRegistry into separate registries, where individual components living in different processes will just consume what they need of the available metadata, retaining at the same time the ability, in the future worker NodeService, to consistently update all the implementations of these interfaces at once.

Because in every process there is only one Meta (for workers, in future, NodeService) that writes metadata in this struct, we don't need to expose the methods to write this data structure.

@slinkydeveloper
Copy link
Contributor

Additional requirement:

  • Flag a service as internal only (that is, only other services can access it) and external only (that is, only accessible from the ingress)

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

Successfully merging a pull request may close this issue.

2 participants