syntax = "proto3";

package go.micro.server;

service File {
	rpc Open(OpenRequest) returns(OpenResponse) {};
	rpc Stat(StatRequest) returns(StatResponse) {};
	rpc Read(ReadRequest) returns(ReadResponse) {};
	rpc Write(WriteRequest) returns(WriteResponse) {};
	rpc Close(CloseRequest) returns(CloseResponse) {};
}

message OpenRequest {
	string filename = 1;
	bool truncate = 2;
}

message OpenResponse {
	int64 id = 1;
	bool result = 2;
}

message CloseRequest {
	int64 id = 1;
}

message CloseResponse {
}

message StatRequest {
	string filename = 1;
}

message StatResponse {
	string type = 1;
	int64 size = 2;
	int64 last_modified = 3;
}

message ReadRequest {
	int64 id = 1;
	int64 offset = 2;
	int64 size = 3;
}

message ReadResponse {
	int64 size = 1;
	bytes data = 2;
	bool eof = 3;
}

message GetRequest {
	int64 id = 1;
	int64 block_id = 2;
}

message GetResponse {
	int64 block_id = 1;
	int64 size = 2;
	bytes data = 3;
}

message WriteRequest {
	int64 id = 1;
	int64 offset = 2;
	bytes data = 3;
}

message WriteResponse {}