示例#1
0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package s3

import (
	"github.com/simonz05/blobserver/blob"
	"github.com/simonz05/util/syncutil"
)

var removeGate = syncutil.NewGate(20) // arbitrary

func (sto *s3Storage) RemoveBlobs(blobs []blob.Ref) error {
	var wg syncutil.Group

	for _, blob := range blobs {
		blob := blob
		removeGate.Start()
		wg.Go(func() error {
			defer removeGate.Done()
			return sto.s3Client.Delete(sto.bucket, blob.String())
		})
	}
	return wg.Err()

}
示例#2
0
// Copyright 2014 Simon Zimmermann. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package swift

import (
	"fmt"

	"github.com/ncw/swift"
	"github.com/simonz05/blobserver/blob"
	"github.com/simonz05/util/log"
	"github.com/simonz05/util/syncutil"
)

var statGate = syncutil.NewGate(20) // arbitrary

func (sto *swiftStorage) StatBlobs(dest chan<- blob.SizedInfoRef, blobs []blob.Ref) error {
	var wg syncutil.Group

	for _, br := range blobs {
		br := sto.createPathRef(br)
		statGate.Start()
		wg.Go(func() error {
			defer statGate.Done()
			ref, cont := sto.refContainer(br)
			log.Println("REF:", ref, cont)
			info, _, err := sto.conn.Object(cont, ref)
			log.Println("Stat:", info, err, ref, br.Path)

			if err == nil {