github.com/cs3org/reva/v2@v2.27.7/pkg/metrics/driver/dummy/dummy.go (about)

     1  // Copyright 2018-2021 CERN
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  // In applying this license, CERN does not waive the privileges and immunities
    16  // granted to it by virtue of its status as an Intergovernmental Organization
    17  // or submit itself to any jurisdiction.
    18  
    19  package dummy
    20  
    21  import (
    22  	"math/rand"
    23  
    24  	"github.com/cs3org/reva/v2/pkg/metrics/config"
    25  	"github.com/cs3org/reva/v2/pkg/metrics/driver/registry"
    26  )
    27  
    28  func init() {
    29  	driver := &MetricsDummyDriver{}
    30  	registry.Register(driverName(), driver)
    31  }
    32  
    33  func driverName() string {
    34  	return "dummy"
    35  }
    36  
    37  // MetricsDummyDriver the MetricsDummyDriver struct
    38  type MetricsDummyDriver struct {
    39  }
    40  
    41  // Configure configures this driver
    42  func (d *MetricsDummyDriver) Configure(c *config.Config) error {
    43  	// no configuration necessary
    44  	return nil
    45  }
    46  
    47  // GetNumUsers returns the number of site users; it's a random number
    48  func (d *MetricsDummyDriver) GetNumUsers() int64 {
    49  	return int64(rand.Intn(30000))
    50  }
    51  
    52  // GetNumGroups returns the number of site groups; it's a random number
    53  func (d *MetricsDummyDriver) GetNumGroups() int64 {
    54  	return int64(rand.Intn(200))
    55  }
    56  
    57  // GetAmountStorage returns the amount of site storage used; it's a random amount
    58  func (d *MetricsDummyDriver) GetAmountStorage() int64 {
    59  	return rand.Int63n(70000000000)
    60  }