Skip to content

Instantly share code, notes, and snippets.

@wkharold
Created March 30, 2014 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkharold/9880360 to your computer and use it in GitHub Desktop.
Save wkharold/9880360 to your computer and use it in GitHub Desktop.
/*** job.go ***/
// Read handles read operations on a jobfile using its associated reader.
func (jf jobfile) Read(fid *srv.FFid, buf []byte, offset uint64) (int, error) {
glog.V(4).Infof("Entering jobfile.Read(%v, %v, %)", fid, buf, offset)
defer glog.V(4).Infof("Exiting jobfile.Read(%v, %v, %v)", fid, buf, offset)
cont := jf.reader()
if offset > uint64(len(cont)) {
return 0, nil
}
contout := cont[offset:]
copy(buf, contout)
return len(contout), nil
}
// Write handles write operations on a jobfile using its associated writer.
func (jf *jobfile) Write(fid *srv.FFid, data []byte, offset uint64) (int, error) {
glog.V(4).Infof("Entering jobfile.Write(%v, %v, %v)", fid, data, offset)
defer glog.V(4).Infof("Exiting jobfile.Write(%v, %v, %v)", fid, data, offset)
jf.Parent.Lock()
defer jf.Parent.Unlock()
return jf.writer(data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment