Module: Tanker

Defined in:
lib/tanker/core/stream.rb,
lib/tanker/error.rb,
lib/tanker/c_tanker.rb,
lib/tanker/core/http.rb,
lib/tanker/core/init.rb,
lib/tanker/core/group.rb,
lib/tanker/core/options.rb,
lib/tanker/core/session.rb,
lib/tanker/core/version.rb,
lib/tanker/c_tanker/c_http.rb,
lib/tanker/core/encryption.rb,
lib/tanker/sharing_options.rb,
lib/tanker/c_tanker/c_future.rb,
lib/tanker/core/verification.rb,
lib/tanker/c_tanker/fork_hook.rb,
lib/tanker/encryption_options.rb,
lib/tanker/c_tanker/c_datastore.rb,
lib/tanker/verification_options.rb,
lib/tanker/c_tanker/c_verification.rb,
lib/tanker/core/encryption_session.rb,
lib/tanker/core/verification_method.rb,
lib/tanker/c_tanker/c_verification_method.rb,
lib/tanker/c_tanker/c_lib.rb

Overview

Because Ruby only has synchronous streams, we can’t read them on Tanker’s thread (in the read callback). To work around that, we start a new Thread for each read operation. This is not that bad because Ruby uses a thread pool behind the scenes and creating a Thread is usually just a work pushed on a queue.

Also, there doesn’t seem to easily create an IO object. The simplest way is to create a pipe. A pipe is a stream where you read everything you write into it. Tanker streams however are pull streams, so there must be something that pulls from the Tanker stream and pushes onto the IO stream. We start a long-running thread for that which just loops.

Because so much is happening in parallel, synchronization is not trivial. There’s one mutex per stream, and we lock that same mutex for every critical section. Here are some important constraints that must be held:

  • Do not copy data to the Tanker buffer if tanker_stream_close has been

called

  • Do not call tanker_stream_read_operation_finish if tanker_stream_close has

been called

  • On the output stream, do not call tanker_stream_read on a closed/closing

stream. Though it is ok to close the stream after the call, but before the future is resolved.

Defined Under Namespace

Modules: Status Classes: Core, E2ePassphraseVerification, E2ePassphraseVerificationMethod, EmailVerification, EmailVerificationMethod, EncryptionOptions, Error, OIDCAuthorizationCodeVerification, OIDCIDTokenVerification, OIDCIDTokenVerificationMethod, Padding, PassphraseVerification, PassphraseVerificationMethod, PhoneNumberVerification, PhoneNumberVerificationMethod, PreverifiedEmailVerification, PreverifiedEmailVerificationMethod, PreverifiedOIDCVerification, PreverifiedPhoneNumberVerification, PreverifiedPhoneNumberVerificationMethod, SharingOptions, Verification, VerificationKeyVerification, VerificationKeyVerificationMethod, VerificationMethod, VerificationOptions