Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:58:19

0001 #!/usr/bin/env python
0002 #
0003 # Licensed under the Apache License, Version 2.0 (the "License");
0004 # You may not use this file except in compliance with the License.
0005 # You may obtain a copy of the License at
0006 # http://www.apache.org/licenses/LICENSE-2.0OA
0007 #
0008 # Authors:
0009 # - Wen Guan, <wen.guan@cern.ch>, 2023
0010 
0011 
0012 """
0013 operations related to throttler.
0014 """
0015 
0016 from idds.common.constants import ThrottlerStatus
0017 from idds.orm.base.session import read_session, transactional_session
0018 from idds.orm import throttlers as orm_throttlers
0019 
0020 
0021 @transactional_session
0022 def add_throttler(site, status=ThrottlerStatus.Active, num_requests=None, num_transforms=None, num_processings=None, new_contents=None,
0023                   queue_contents=None, others=None, session=None):
0024     """
0025     Add a throttler item
0026 
0027     :param site: The site name.
0028     :param session: The database session.
0029     """
0030     return orm_throttlers.add_throttler(site=site, status=status, num_requests=num_requests, num_transforms=num_transforms,
0031                                         num_processings=num_processings, new_contents=new_contents, queue_contents=queue_contents,
0032                                         others=others, session=session)
0033 
0034 
0035 @read_session
0036 def get_throttlers(site=None, status=None, session=None):
0037     """
0038     Get throttler
0039 
0040     :param site: site name.
0041     :param status: throttler status.
0042     """
0043     return orm_throttlers.get_throttlers(site=site, status=status, session=session)
0044 
0045 
0046 @transactional_session
0047 def update_throttler(throttler_id=None, site=None, parameters=None, session=None):
0048     """
0049     Update throttler
0050 
0051     :param throttler_id: throttler id.
0052     :param parameters: parameters in dict.
0053     """
0054     return orm_throttlers.update_throttler(throttler_id=throttler_id, site=site, parameters=parameters, session=session)
0055 
0056 
0057 @transactional_session
0058 def delete_throttler(throttler_id, session=None):
0059     """
0060     Delete throttler with the given id.
0061 
0062     :param throttler_id: The throttler id.
0063     """
0064     return orm_throttlers.delete_throttler(throttler_id=throttler_id, session=session)