golemcloud / golem

Golem is an open source durable computing platform that makes it easy to build and deploy highly reliable distributed systems.
https://learn.golem.cloud/
Apache License 2.0
530 stars 59 forks source link

Introduce cors, better binding structure, rewrite certain modules and make ways for worker authentication #1057

Closed afsalthaj closed 1 week ago

afsalthaj commented 1 week ago

Fixes #921

Design doc here

The code changes have also taken worker authentication design [doc](WorkerGateway Authentication design doc into consideration.

TODO

It took a bit of time than I thought for resolving conflicts and make necessary changes to get the file server tests working again.

Note that the new module structure will help with separating it out completely

New module structure (focused on separating it out in future)

Before, it was the following
├── api
│   ├── common.rs
│   ├── custom_http_request_api.rs
│   ├── error.rs
│   ├── healthcheck.rs
│   ├── mod.rs
│   └── register_api_definition_api.rs
├── api_definition
│   ├── api_common.rs
│   ├── http
│   │   ├── http_api_definition.rs
│   │   ├── http_oas_api_definition.rs
│   │   └── mod.rs
│   └── mod.rs
├── app_config.rs
├── getter.rs
├── headers.rs
├── http
│   ├── http_request.rs
│   ├── mod.rs
│   └── router
│       ├── core.rs
│       ├── mod.rs
│       ├── pattern.rs
│       └── tree.rs
├── lib.rs
├── metrics.rs
├── openapi_yaml.rs
├── parser
│   ├── mod.rs
│   ├── path_pattern_parser.rs
│   └── place_holder_parser.rs
├── path.rs
├── repo
│   ├── api_definition.rs
│   ├── api_deployment.rs
│   └── mod.rs
├── service
│   ├── api_definition.rs
│   ├── api_definition_lookup.rs
│   ├── api_definition_validator.rs
│   ├── api_deployment.rs
│   ├── component
│   │   ├── default.rs
│   │   ├── error.rs
│   │   └── mod.rs
│   ├── http
│   │   ├── http_api_definition_validator.rs
│   │   └── mod.rs
│   ├── mod.rs
│   └── worker
│       ├── connect_proxy.rs
│       ├── default.rs
│       ├── error.rs
│       ├── mod.rs
│       ├── routing_logic.rs
│       └── worker_stream.rs
├── worker_binding
│   ├── compiled_golem_worker_binding.rs
│   ├── fileserver_binding_handler.rs
│   ├── golem_worker_binding.rs
│   ├── mod.rs
│   ├── request_details.rs
│   ├── rib_input_value_resolver.rs
│   └── worker_binding_resolver.rs
├── worker_bridge_execution
│   ├── content_type_mapper.rs
│   ├── mod.rs
│   ├── to_response.rs
│   └── worker_request_executor.rs
├── worker_service_rib_compiler
└── worker_service_rib_interpreter
Now, it is (gateway responsibilities are well separated out)

.
├── api
│   ├── common.rs
│   ├── custom_http_request_api.rs
│   ├── error.rs
│   ├── healthcheck.rs
│   ├── mod.rs
│   └── register_api_definition_api.rs
├── gateway_api_definition
│   ├── api_common.rs
│   ├── http
│   │   ├── http_api_definition.rs
│   │   ├── http_oas_api_definition.rs
│   │   ├── mod.rs
│   │   ├── path_pattern_parser.rs
│   │   └── place_holder_parser.rs
│   └── mod.rs
├── gateway_api_deployment
│   ├── http
│   │   └── mod.rs
│   └── mod.rs
├── gateway_binding
│   ├── gateway_binding_compiled.rs
│   ├── mod.rs
│   ├── static_binding.rs
│   ├── worker_binding.rs
│   └── worker_binding_compiled.rs
├── gateway_execution
│   ├── api_definition_lookup.rs
│   ├── file_server_binding_handler.rs
│   ├── gateway_binding_executor.rs
│   ├── gateway_binding_resolver.rs
│   ├── gateway_worker_request_executor.rs
│   ├── http_content_type_mapper.rs
│   ├── mod.rs
│   ├── rib_input_value_resolver.rs
│   ├── router
│   │   ├── core.rs
│   │   ├── mod.rs
│   │   ├── pattern.rs
│   │   └── tree.rs
│   └── to_response.rs
├── gateway_middleware
│   ├── http
│   │   ├── cors.rs
│   │   ├── http_middleware.rs
│   │   └── mod.rs
│   └── mod.rs
├── gateway_request
│   ├── http_request.rs
│   ├── mod.rs
│   └── request_details.rs
├── gateway_rib_compiler
│   └── mod.rs
├── gateway_rib_interpreter
│   └── mod.rs
│   ├── api_definition.rs
│   ├── api_deployment.rs
│   └── mod.rs
└── service
    ├── component
    │   ├── default.rs
    │   ├── error.rs
    │   └── mod.rs
    ├── gateway
    │   ├── api_definition.rs
    │   ├── api_definition_transformer.rs
    │   ├── api_definition_validator.rs
    │   ├── api_deployment.rs
    │   ├── http_api_definition_validator.rs
    │   └── mod.rs
    ├── mod.rs
    └── worker
        ├── connect_proxy.rs
        ├── default.rs
        ├── error.rs
        ├── mod.rs
        ├── routing_logic.rs
        └── worker_stream.rs
├── app_config.rs
├── getter.rs
├── headers.rs
├── lib.rs
├── metrics.rs
├── openapi_yaml.rs
├── path.rs
├── repo