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

Add Tapioca compiler #533

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add Tapioca compiler #533

wants to merge 1 commit into from

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jan 15, 2025

No description provided.

@st0012 st0012 force-pushed the add-tapioca-compiler branch 2 times, most recently from c189641 to a80d9ea Compare January 15, 2025 19:39
Copy link
Contributor

@Mangara Mangara left a comment

Choose a reason for hiding this comment

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

I forgot this initially - can we generate a signature for perform as well? It'll be the same type signature as perform_now, but an instance method, instead of a class method.

@st0012 st0012 force-pushed the add-tapioca-compiler branch 3 times, most recently from 3424803 to c76569d Compare January 15, 2025 21:36
lib/tapioca/dsl/compilers/job_iteration.rb Outdated Show resolved Hide resolved
end
end

def compile_method_parameters_to_rbi(method_def)
Copy link
Member

Choose a reason for hiding this comment

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

Do you need to copy this complex method over? I would have instead done a call to compile_method_parameters_to_rbi and then walked over the result to find all required params of type T::Types:FixedHash and replace them with the keyword parameters instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

I want to do that too but AFAICT the T::Types information is not captured in the rbi types:

<RBI::TypedParam param=#<RBI::ReqParam:0x000000013295e420 @comments=[], @loc=nil, @name="params", @parent_tree=nil> type="{shop_id: ::Integer, resource_types: T::Array[::ResourceType], locale: ::Locale, metadata: T.nilable(::String)}">

Copy link
Member

Choose a reason for hiding this comment

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

Right, but you can always match that data with method_types = parameters_types_from_signature(method_def, signature) to find all required params of that type.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, those are also strings. I guess you could do:

signature = signature_of(method_def)
fixed_hash_args = signature.arg_types.select { |arg_type| arg_type[1].is_?(T::Types::FixedHash) }

and loop over those to match the params to the ones you need to replace.

It takes the job's `build_enumerator` method and generates the signatures
for the job's corresponding `perform_later` and `perform_now` methods.
@st0012 st0012 force-pushed the add-tapioca-compiler branch from 090d72e to fceeb76 Compare January 16, 2025 16:57
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

Successfully merging this pull request may close these issues.

3 participants