Skip to content

Add Executable abstraction #73

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

Open
0xivanov opened this issue Mar 31, 2025 · 0 comments · May be fixed by #76
Open

Add Executable abstraction #73

0xivanov opened this issue Mar 31, 2025 · 0 comments · May be fixed by #76
Labels
enhancement New feature or request

Comments

@0xivanov
Copy link

0xivanov commented Mar 31, 2025

Problem

Currently most of the execution logic is done in the Client class. The client should handle mostly network configurations.

Solution

Implement an abstract mechanism to handle execution processes, including retries, backoffs, and node health assessments.
The first iteration for Executable can have only a few features:

type Executable interface {
	shouldRetry() // retries depending on response status code
	makeRequest() interface{} // builds the grpc body
	getMethod(*_Channel) _Method // get the grpc method
}

Since python uses stubs as it's grpc communication, we could take logic from the go sdk and create Channel class which holds all the GRPC services:

type Channel struct {
        // these are protobuf defined grpc servies and each one has specific methods
	crypto      services.CryptoServiceClient
	file        services.FileServiceClient
	contract    services.SmartContractServiceClient
	topic       services.ConsensusServiceClient
	freeze      services.FreezeServiceClient
	network     services.NetworkServiceClient
	token       services.TokenServiceClient
	schedule    services.ScheduleServiceClient
	util        services.UtilServiceClient
	addressBook services.AddressBookServiceClient
	client      *grpc.ClientConn
}

Every transaction or query needs to have getMethod func that creates grpc stub using the grpc definitions:

func (q *AccountInfoQuery) getMethod(channel *_Channel) _Method {
	return _Method{
		query: channel._GetCrypto().GetAccountInfo,
	}
}
@0xivanov 0xivanov added the enhancement New feature or request label Mar 31, 2025
@Dosik13 Dosik13 linked a pull request Apr 3, 2025 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant