[Notes] [Git][BuildStream/buildstream][raoul/802-refactor-artifactcache] cas: move push_message into CASRemote



Title: GitLab

Raoul Hidalgo Charman pushed to branch raoul/802-refactor-artifactcache at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/_artifactcache.py
    ... ... @@ -733,7 +733,7 @@ class ArtifactCache():
    733 733
                                     "servers are configured as push remotes.")
    
    734 734
     
    
    735 735
             for remote in push_remotes:
    
    736
    -            message_digest = self.cas.push_message(remote, message)
    
    736
    +            message_digest = remote.push_message(message)
    
    737 737
     
    
    738 738
             return message_digest
    
    739 739
     
    

  • buildstream/_cas/cascache.py
    ... ... @@ -19,7 +19,6 @@
    19 19
     
    
    20 20
     import hashlib
    
    21 21
     import itertools
    
    22
    -import io
    
    23 22
     import os
    
    24 23
     import stat
    
    25 24
     import tempfile
    
    ... ... @@ -331,29 +330,6 @@ class CASCache():
    331 330
     
    
    332 331
             self._send_directory(remote, directory.ref)
    
    333 332
     
    
    334
    -    # push_message():
    
    335
    -    #
    
    336
    -    # Push the given protobuf message to a remote.
    
    337
    -    #
    
    338
    -    # Args:
    
    339
    -    #     remote (CASRemote): The remote to push to
    
    340
    -    #     message (Message): A protobuf message to push.
    
    341
    -    #
    
    342
    -    # Raises:
    
    343
    -    #     (CASError): if there was an error
    
    344
    -    #
    
    345
    -    def push_message(self, remote, message):
    
    346
    -
    
    347
    -        message_buffer = message.SerializeToString()
    
    348
    -        message_digest = utils._message_digest(message_buffer)
    
    349
    -
    
    350
    -        remote.init()
    
    351
    -
    
    352
    -        with io.BytesIO(message_buffer) as b:
    
    353
    -            remote._send_blob(message_digest, b)
    
    354
    -
    
    355
    -        return message_digest
    
    356
    -
    
    357 333
         # objpath():
    
    358 334
         #
    
    359 335
         # Return the path of an object based on its digest.
    

  • buildstream/_cas/casremote.py
    1 1
     from collections import namedtuple
    
    2
    +import io
    
    2 3
     import os
    
    3 4
     import multiprocessing
    
    4 5
     import signal
    
    ... ... @@ -229,6 +230,28 @@ class CASRemote():
    229 230
     
    
    230 231
             return True
    
    231 232
     
    
    233
    +    # push_message():
    
    234
    +    #
    
    235
    +    # Push the given protobuf message to a remote.
    
    236
    +    #
    
    237
    +    # Args:
    
    238
    +    #     message (Message): A protobuf message to push.
    
    239
    +    #
    
    240
    +    # Raises:
    
    241
    +    #     (CASError): if there was an error
    
    242
    +    #
    
    243
    +    def push_message(self, message):
    
    244
    +
    
    245
    +        message_buffer = message.SerializeToString()
    
    246
    +        message_digest = utils._message_digest(message_buffer)
    
    247
    +
    
    248
    +        self.init()
    
    249
    +
    
    250
    +        with io.BytesIO(message_buffer) as b:
    
    251
    +            self._send_blob(message_digest, b)
    
    252
    +
    
    253
    +        return message_digest
    
    254
    +
    
    232 255
         ################################################
    
    233 256
         #             Local Private Methods            #
    
    234 257
         ################################################
    

  • buildstream/sandbox/_sandboxremote.py
    ... ... @@ -310,12 +310,12 @@ class SandboxRemote(Sandbox):
    310 310
     
    
    311 311
                 # Push command and action
    
    312 312
                 try:
    
    313
    -                cascache.push_message(casremote, command_proto)
    
    313
    +                casremote.push_message(command_proto)
    
    314 314
                 except grpc.RpcError as e:
    
    315 315
                     raise SandboxError("Failed to push command to remote: {}".format(e))
    
    316 316
     
    
    317 317
                 try:
    
    318
    -                cascache.push_message(casremote, action)
    
    318
    +                casremote.push_message(action)
    
    319 319
                 except grpc.RpcError as e:
    
    320 320
                     raise SandboxError("Failed to push action to remote: {}".format(e))
    
    321 321
     
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]