nsq源码分析backend_queue.go

来源:互联网 发布:linux mv 文件夹 编辑:程序博客网 时间:2024/06/05 09:53

backend_queue.go

// BackendQueue represents the behavior for the secondary message// storage systemtype BackendQueue interface {    Put([]byte) error    ReadChan() chan []byte // this is expected to be an *unbuffered* channel    Close() error    Delete() error    Depth() int64    Empty() error}

类是对数据和方法的抽象和封装,那么接口就是对类的抽象。
使用接口的好处是非常灵活,这样就与具体的实现做了解耦,如果以后有其他的实现类,只需要实现接口就可以了,而不用去改使用的时候的代码。

原创粉丝点击